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

Map operation fails with "Error 4089: Can't get real value of map" #724

Closed
f-ishikawa opened this issue May 25, 2020 · 3 comments
Closed
Labels
bug Incorrect behaviour of the tool language Issues in parser, TC, interpreter, POG or CG Mergable A fix is available on a branch to merge for release
Milestone

Comments

@f-ishikawa
Copy link

f-ishikawa commented May 25, 2020

Description

The domain restriction operation for a map fails with an error.

Steps to Reproduce

Using 2.7.4, the following operations lead to
Error 4089: Can't get real value of map in 'Test2'

public test1a : () ==> ()
test1a() == (
dcl m : map token to int := { mk_token(1) |-> 1 };
m := {mk_token(1)} <:- m;
);

public test1b : () ==> ()
test1b() == (
dcl m : map int to int := { 1 |-> 2 };
m := {1} <:- m;
);

@nickbattle
Copy link
Contributor

Thanks for reporting this. There is definitely something strange here, but the domain restriction operator is <-: rather than <:-. If you change that, it appears to work correctly(?). So I need to look at why or how <:- parses without an error. I'll investigate.

@nickbattle
Copy link
Contributor

So setval <:- mapval parses as setval <: (-mapval). But for some reason, the type check of a unary minus is not checking that the argument is numeric. So for example -"Hello" does not cause a type checking error (it causes a runtime error, of course).

So in your case, it was trying to "cast" a map to a numeric value, which in the general case is real. Hence the error, cannot get real value of map.

The fix looks relatively simple. Just checking it now.

@nickbattle nickbattle added bug Incorrect behaviour of the tool language Issues in parser, TC, interpreter, POG or CG Mergable A fix is available on a branch to merge for release labels May 25, 2020
@nickbattle
Copy link
Contributor

Now fixed in ncb/development.

@idhugoid idhugoid added this to the v3.0.0 milestone Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behaviour of the tool language Issues in parser, TC, interpreter, POG or CG Mergable A fix is available on a branch to merge for release
Projects
None yet
Development

No branches or pull requests

3 participants