Skip to content

Commit

Permalink
Add test case for enum type matching fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Sep 30, 2017
1 parent 48dca0b commit 2a672b2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions flattening/modelica/enums/EnumFuncRel.mo
@@ -0,0 +1,30 @@
// name: EnumFuncRel
// keywords:
// status: incorrect
//
// Checks that a function reference to a function returning an enumeration can't
// be used as an enumeration value.
//

type E = enumeration(one, two, three);

function f
output E e = E.one;
end f;

function EnumFuncRel
algorithm
if f == E.one then
end if;
end EnumFuncRel;

// Result:
// Error processing file: EnumFuncRel.mo
// [flattening/modelica/enums/EnumFuncRel.mo:17:3-18:9:writable] Error: Cannot resolve type of expression f == E.one. The operands have types .f<function>() => #enumeration(one, two, three), enumeration(one, two, three) in component <NO COMPONENT>.
// Error: Error occurred while flattening model EnumFuncRel
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult
1 change: 1 addition & 0 deletions flattening/modelica/enums/Makefile
Expand Up @@ -22,6 +22,7 @@ EnumDimSum.mo \
EnumFor.mo \
EnumFor2.mo \
EnumFuncIf.mo \
EnumFuncRel.mo \
EnumInnerOuterDim.mo \
EnumInvalidLiteral.mo \
EnumMatrixProduct.mo \
Expand Down
2 changes: 1 addition & 1 deletion flattening/modelica/types/IntegerToEnumeration.mo
Expand Up @@ -52,7 +52,7 @@ end IntegerToEnumeration;
// end if;
// end when;
// when time > 0.4 then
// if 2 == e then
// if IntegerToEnumeration.Enum$e.two == e then
// z := 2;
// else
// z := -2;
Expand Down

0 comments on commit 2a672b2

Please sign in to comment.