-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for variables in value bindings #869
Conversation
The parser/resolver and value binding work is done. The PR is marked as WIP because static commands are not working right now. |
It now should work even in static commands. Arguably, the translation is a bit messy, but it works - we can probably improve the output JS code later. |
The syntax is `val variableName = value; nextExpression`. The variable is not assignable again - it is always immutable. Variable may shadow property names and variables defined ahead of it. The variable may be accessed only in the `nextExpression`. This version does not support automatic unwrapping Tasks. We wanted to switch to using await in DotVVM 3 anyway, right? see #776
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
@@ -934,6 +934,29 @@ public void BindingParser_MultiblockExpression_EmptyBlockMiddle_Invalid(string b | |||
Assert.AreEqual(node.EndPosition, lastExpression.EndPosition); | |||
Assert.AreEqual(voidBlockExpectedLenght, middleExpression.Length); | |||
|
|||
} | |||
[DataRow("var x=A(); !x", "x", DisplayName = "Variable (val) expression")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val
instead of var
in DisplayName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
The syntax is
val variableName = value; nextExpression
.The variable is not assignable again - it is always immutable.
Variable may shadow property names and variables defined ahead of it.
The variable may be accessed only in the
nextExpression
.This version does not support automatic unwrapping Tasks.
We wanted to switch to using await in DotVVM 3 anyway, right?
see #776