Opened 14 years ago
Last modified 14 years ago
#1560 closed defect (wontfix)
Erroneous MetaModelica error for match expression
| Reported by: | Per Östlund | Owned by: | Per Östlund |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Version: | ||
| Keywords: | Cc: | Per Östlund, Martin Sjölund |
Description
The following doesn't work when compiling with +g=MetaModelica:
package test
function f
input list<String> inStrs;
output list<String> outStrs;
algorithm
outStrs := match(inStrs)
local
// This doesn't work:
case ("this" :: _) then {"this"};
// This does work:
case ("this" :: _)
equation
s = {"this"};
then
s;
else inStrs;
end match;
end f;
constant list<String> str = f({"this", "isn't", "working!"});
end test;
The following error is generated:
[test.mo:6:5-11:14:writable] Error: Match expression has mismatched result types: list<String> String[1]
This pattern is used by Tpl.takeLineOrString, which makes it impossible to call that function (or any function that uses that function) from a mos-script. It's easy to work around by introducing an extra variable though.
Note:
See TracTickets
for help on using tickets.

Works with +d=rml (problem in the language specification; fixed in MetaModelica 2.0 which will be implemented when someone feels like it)