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

Membership test does not work with objects #216

Open
ghewgill opened this issue Mar 4, 2019 · 1 comment
Open

Membership test does not work with objects #216

ghewgill opened this issue Mar 4, 2019 · 1 comment
Labels

Comments

@ghewgill
Copy link
Owner

ghewgill commented Mar 4, 2019

> VAR x: Object := 4
> VAR a: Array<Object> := [3, 4, "foo"]
> x IN a
FALSE
@ghewgill ghewgill added the bug label Mar 4, 2019
@ghewgill
Copy link
Owner Author

This gets deeper.

> a := [1, 2, x]
> x IN a
FALSE
> a := [1, "two", x]
> x IN a
TRUE

The problem here is that in the first case, the literal array is resolved to type "array of number", because every array element can be converted to Number. So although a is declared as Array<Object>, the literal array starts off as Array<Number> and then is converted to Array<Object>.

In the second case, the literal array is resolved as "array of object" because the types are different. So the identity of x remains the same in the array and x IN a is true.

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

No branches or pull requests

1 participant