Opened 8 years ago
#4094 new enhancement
Assignment to _ should probably be illegal
Reported by: | Per Östlund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | normal | Milestone: | Future |
Component: | MetaModelica | Version: | |
Keywords: | Cc: |
Description
MetaModelica currently allows assigning to _, like this:
_ := match something case 1 then 1; case 2 then 2; end match;
This can easily occur if you change the return values of the match-statement but forget to change the lhs of the expression, and the compiler will happily accept it. But it can lead to subtle issues that can be annoying to debug, like the compiler removing the last statement in a case because it thinks it's not used.
Since () is more correct than _ when a match-statement shouldn't return anything, I think it would make sense to forbid assignment to _.
Note:
See TracTickets
for help on using tickets.