You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parameter hoisting necessary for default parameter expressions referencing other parameters changes the evaluation order of the call arguments.
Example
proca(x: int, y: int, z = y +1) =discardprocb(x: int, y: int, z = y + x) =# the order of usage is significant!discarda((echo"a"; 1), (echo"b"; 2)) # 1b((echo"c"; 1), (echo"d"; 2)) # 2
Actual Output
b
a
d
c
Expected Output
a
b
c
d
Additional Information
The underlying issue is with how the parameter hoisting commits the argument expression for the hoisted parameters to temporaries:
call(x = a, y = b, z = y +1) # `y` needs to be hoisted# is transformed intolet
:tmp = b
call(a, :tmp, :tmp +1)
If a has side-effects, the transformation changes the program's meaning (case number 1).
In case number 2, both parameter are hoisted, but in the order of in which they're used and not in the order in which the parameter are specified.
To preserve the meaning of the program, if a parameter is hoisted, all preceding parameters need to be hoisted too. In addition, parameters always need to be hoisted from left to right.
The text was updated successfully, but these errors were encountered:
The parameter hoisting necessary for default parameter expressions referencing other parameters changes the evaluation order of the call arguments.
Example
Actual Output
Expected Output
Additional Information
The underlying issue is with how the parameter hoisting commits the argument expression for the hoisted parameters to temporaries:
If
a
has side-effects, the transformation changes the program's meaning (case number 1).In case number 2, both parameter are hoisted, but in the order of in which they're used and not in the order in which the parameter are specified.
To preserve the meaning of the program, if a parameter is hoisted, all preceding parameters need to be hoisted too. In addition, parameters always need to be hoisted from left to right.
The text was updated successfully, but these errors were encountered: