Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string comparison #67

Open
boogie opened this issue Apr 14, 2023 · 2 comments
Open

string comparison #67

boogie opened this issue Apr 14, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@boogie
Copy link

boogie commented Apr 14, 2023

I'm not sure if it's my implementation or an issue with the engine, but string comparison operators greater and smaller than are causing an abort.

let x = '0';
let y = '9';
let result = x < y; // abort()

It seems that there's a test for it which is working properly, and I can confirm there's no issue with the JavaScript based engine, but it is not working with the C engine for me.

@boogie
Copy link
Author

boogie commented Apr 15, 2023

I've checked the C implementation, and as I see the code is translated to VM_OP_NUM_OP bytecode, and only +, === and !== are type independent, but <, <=, >, >=, -, /, %, **, and * are only working with numbers.

What is the plan related to this? It is not mentioned at the "Supported Language" doc page, so I was surprised. It can be OK, however I would expect a runtime error, not an abort. Abort cannot be catched and handled.

@coder-mike
Copy link
Owner

Ah. Honestly, I didn't even think of that one. The operators like **, *, /, %, and - all coerce their operands to numbers. It didn't occur to me that inequality operators don't do this, but it's obvious in hindsight.

I'll add it to the to-do list and in the meantime I'll note it in the supported language doc page.

@coder-mike coder-mike added the enhancement New feature or request label Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants