You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The collections are actually concatenated. It seems to happen only when the left operand of += is a dynamic attribute (declared in ALE) or a local variable.
Origin of the issue
Due to Java's type erasure it is a bit hard to deal with heterogeneous collections at runtime. I guess they can be concatenated here because EMF allocates an EObject[] array when the variable is dynamic, and a more specific array when the feature is declared in Ecore.
How to fix
This is not straightforward to fix because the interpreter (MethodEvaluator):
has no access to the declared type of a variable
could be solved by keeping all declarations (see variablesStack and caseVariableDeclaration)
cannot evaluate the type of a value
might be solved by using an InsertionStrategy but it may likely require to validate the program first (as done by the type checker).
Anyway, the interpreter shouldn't know less about the program than the type checker. We have to address this.
How to test
There are already two tests in EvalTest, ready but ignored: this one and that one.
The text was updated successfully, but these errors were encountered:
Expected behavior
The interpreter stops its execution and prints an error when an attempt to concatenate two collections with incompatible types:
Current behavior
The collections are actually concatenated. It seems to happen only when the left operand of
+=
is a dynamic attribute (declared in ALE) or a local variable.Origin of the issue
Due to Java's type erasure it is a bit hard to deal with heterogeneous collections at runtime. I guess they can be concatenated here because EMF allocates an
EObject[]
array when the variable is dynamic, and a more specific array when the feature is declared in Ecore.How to fix
This is not straightforward to fix because the interpreter (MethodEvaluator):
variablesStack
andcaseVariableDeclaration
)InsertionStrategy
but it may likely require tovalidate
the program first (as done by the type checker).Anyway, the interpreter shouldn't know less about the program than the type checker. We have to address this.
How to test
There are already two tests in
EvalTest
, ready but ignored: this one and that one.The text was updated successfully, but these errors were encountered: