mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Restriction of switch
This commit is contained in:
parent
15ca987048
commit
e9b08e029e
@ -90,7 +90,7 @@ Grammar::
|
||||
Switch =
|
||||
'switch' Expression Case* ( 'default' ':' Block )?
|
||||
Case =
|
||||
'case' Expression ':' Block
|
||||
'case' Literal ':' Block
|
||||
ForLoop =
|
||||
'for' Block Expression Block Block
|
||||
BreakContinue =
|
||||
@ -120,6 +120,11 @@ the block they are defined in (including all sub-nodes and sub-blocks).
|
||||
Shadowing is disallowed, i.e. you cannot declare an identifier at a point
|
||||
where another identifier with the same name is also visible.
|
||||
|
||||
Switches must have at least one (or the default) and at most one default case.
|
||||
If all possible values of the expression is covered, the default case should
|
||||
not be allowed (i.e. a switch with a ``bool`` expression and having both a
|
||||
true and false case should not allow a default case).
|
||||
|
||||
In for-loops, identifiers declared in the first block (the init block)
|
||||
are visible in all other parts of the for loop (but not outside of the loop).
|
||||
Identifiers declared in the other parts of the for loop respect the regular
|
||||
|
Loading…
Reference in New Issue
Block a user