Closed neumantm closed 1 year ago
Since your if statement does not have an else clause, any names defined inside the "then" clause of the statement are considered to have multiplicity lower bound of 0 after the if statement. This is true regardless of the fact that, in this case, the if condition is "true" so the "then" clause is always evaluated.
The input parameter WriteLine
activity has multiplicity 1..1, so, after the if statement, the multiplicity lower bound of 0 for a
is incompatible. If you change WriteLine(a);
to WriteLine(a ?? "");
, then it will parse and execute as you would expect.
Alternatively, you can try something like
activity Test3() {
if(true) {
let a : String = "a";
} else {
let a : String = "b";
}
WriteLine(a);
}
As coded above, this will write "a". If you change true
to false
, then it will write "b".
Ah I see, thanks and sorry for the noise.
If I understand the standard correctly (especially the
Names
subsection in the section9.8 if Statement
) the following code should compile and execute successfully and outputa
:However when trying to run/compile that code with the reference implementation I get the following error:
The same problem appears to exist for while statements (and maybe more, but I did not test that). The Block Statement, however, works as I'd expect:
outputs
a
.Did I misunderstand the standard, or is this a bug in the reference implementation?