-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support let
bindings in Effect
blocks
#95
Conversation
box expression, | ||
box rest, | ||
} => { | ||
// REVIEW: could just drop the unused assignment altogether? |
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.
I don't necessarily want to do this because we might want to...
let _ = Debug.spy(some_value);
} => { | ||
// REVIEW: could just drop the unused assignment altogether? | ||
Block::ConstAssignment { | ||
ident: Ident::from(unused_name), |
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.
This might blowup if we have something like...
let _ = 1;
let _ = 2;
let _ = 3;
In which case we could end generating dodgy const
assignments, i.e.
const _ = 1;
const _ = 2; // Identifier '_' has already been declared
const _ = 3;
Codecov Report
@@ Coverage Diff @@
## main #95 +/- ##
==========================================
+ Coverage 73.90% 74.03% +0.12%
==========================================
Files 111 111
Lines 8319 8406 +87
==========================================
+ Hits 6148 6223 +75
- Misses 2171 2183 +12
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This allows pure variable binding in
Effect
blocks. For example:Of course the above is a bit redundant (and should probably be rewritten as part of the JS codegen 👀 ) but this is useful in less trivial cases.
It's particularly useful as we don't currently support patterns on the left-hand side of effect binds (
<-
, due to parsing restrictions).So eventually this will be nice for code like:
Also note that as part of this I had to add a fresh variable
supply
to the JavaSCript code generator, so that we can use generated variables without risking badconst
assignments (i.e.Identifier 'x' has already been declared
).