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

Undefined or not initialized variables with strange behavior #1458

Open
EduFrazao opened this issue Mar 21, 2024 · 2 comments
Open

Undefined or not initialized variables with strange behavior #1458

EduFrazao opened this issue Mar 21, 2024 · 2 comments

Comments

@EduFrazao
Copy link

EduFrazao commented Mar 21, 2024

Hi. Undefined or not initialized variables presents a strange behavior in version 1.7.14

Like this code:

var x = undefined;

if (!x) {
    // Never enters here
}

Not initialized variables also reports its types as strings

var x;
print(typeof x)

This codes prints: "string"

Is this somehow expected?

Edit note:
With 1.7.13 works fine.

@zozo-yasuda
Copy link

I tested in the current 1.7.15 snapshot, indeed:

var x = undefined;
if(x) print(x)  //yields nothing
if(!x) print(x) //prints "undefined"

I also checked Boolean(undefined). This evaluates to false as it should, so maybe there's something wrong with the if logic.
For the second issue, mine printed undefined so this was probably fixed.

I'll add these as test cases when I familiarize myself more with the repo.

@EduFrazao
Copy link
Author

I tested in the current 1.7.15 snapshot, indeed:

var x = undefined;
if(x) print(x)  //yields nothing
if(!x) print(x) //prints "undefined"

I also checked Boolean(undefined). This evaluates to false as it should, so maybe there's something wrong with the if logic. For the second issue, mine printed undefined so this was probably fixed.

I'll add these as test cases when I familiarize myself more with the repo.

Hi. Thanks for testing.
Did you test the output of "typeof x" after set it as undefined?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants