usethesource / rascal

The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
http://www.rascal-mpl.org
Other
408 stars 77 forks source link

Add-assign of incompatible set types does not raise error #2056

Closed toinehartman closed 1 month ago

toinehartman commented 1 month ago

Describe the bug

Add-assigning two sets with elements of incompatible types does not raise a static error, but crashes during interpretation.

To Reproduce

set[int] s1 = {0};
set[str] s2 = {"foo"};
s1 += s2; // No static error, but `UnexpectedType` exception from interpreter
s1 = s2;  // Static error: Cannot assign righthand side of type `set[str]` to lefthand side of type `set[int]`

Expected behavior A static error from the type checker, like the one for assignment

Desktop:

PaulKlint commented 1 month ago

Very good observation and nice reproduction of this error. Indeed checks were missing for composite assignment operators like +=, -=, /= etc. Fixed.