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

Maps of Record types sometimes fail #734

Closed
nickbattle opened this issue Aug 13, 2020 · 2 comments
Closed

Maps of Record types sometimes fail #734

nickbattle opened this issue Aug 13, 2020 · 2 comments
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

@nickbattle
Copy link
Contributor

Under some circumstances, maps that are comprised of record values of different types can cause NullPointerExceptions to be raised. The minimum test case is:

types
    P :: ;
    
    Q :: ;
    
    R :: ;
    
values
    V : map P | Q | R to nat =
    {
	mk_P() |-> 1, 
	mk_Q() |-> 2,
	mk_R() |-> 3
    };

This fails at initialization (of the V value) with a null pointer exception.

@nickbattle nickbattle added bug Incorrect behaviour of the tool language Issues in parser, TC, interpreter, POG or CG labels Aug 13, 2020
@nickbattle
Copy link
Contributor Author

This was caused by the return value from RecordValue.compareTo when the arguments are records of different types. By returning the fixed value Integer.MIN_VALUE, it violates the compareTo contract which must return sgn(x<y) = -sgn(y<x). Changing this to user the super.compareTo fixes the bug.

@nickbattle nickbattle added the Mergable A fix is available on a branch to merge for release label Aug 13, 2020
@nickbattle
Copy link
Contributor Author

Fix now 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

2 participants