-
Notifications
You must be signed in to change notification settings - Fork 119
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
Soak operations should allow undeclared variables #801
Labels
Comments
alangpierce
added a commit
to alangpierce/decaffeinate
that referenced
this issue
Feb 18, 2017
Progress toward decaffeinate#801 Progress toward decaffeinate#336 Now, with a simple soak expression like `a?.b`, it will be expanded into a ternary rather than using the `__guard__` function. This allows us to handle the case where the variable is unbound (in which case the code should return `undefined` rather than throwing an exception). More specifically, we use the conditional form of soak operations As described in decaffeinate#336, I separate the expression and statement cases and prefer to wrap in an `if` if possible. This only handles the case for normal soaked member access; a later commit will expand it to soaked dynamic member access and soaked function application. Also fix a subtle bug in repeatable expression patching where a paren could be misplaced.
alangpierce
added a commit
to alangpierce/decaffeinate
that referenced
this issue
Feb 18, 2017
Progress toward decaffeinate#801 Progress toward decaffeinate#336 Now, with a simple soak expression like `a?.b`, it will be expanded into a ternary rather than using the `__guard__` function. This allows us to handle the case where the variable is unbound (in which case the code should return `undefined` rather than throwing an exception). More specifically, we use the conditional form of soak operations As described in decaffeinate#336, I separate the expression and statement cases and prefer to wrap in an `if` if possible. This only handles the case for normal soaked member access; a later commit will expand it to soaked dynamic member access and soaked function application. Also fix a subtle bug in repeatable expression patching where a paren could be misplaced.
alangpierce
added a commit
that referenced
this issue
Feb 19, 2017
Progress toward #801 Progress toward #336 Now, with a simple soak expression like `a?.b`, it will be expanded into a ternary rather than using the `__guard__` function. This allows us to handle the case where the variable is unbound (in which case the code should return `undefined` rather than throwing an exception). More specifically, we use the conditional form of soak operations As described in #336, I separate the expression and statement cases and prefer to wrap in an `if` if possible. This only handles the case for normal soaked member access; a later commit will expand it to soaked dynamic member access and soaked function application. Also fix a subtle bug in repeatable expression patching where a paren could be misplaced.
alangpierce
added a commit
to alangpierce/decaffeinate
that referenced
this issue
Feb 19, 2017
Fixes decaffeinate#801 Progress toward decaffeinate#336 We now use a conditional for soaked dynamic member access and soaked function calls as long as the expression is repeatable and does not contain any soak operations. This is pretty much the same strategy as for soaked member accesses. For function calls, the code naturally becomes method call syntax when necessary, so we don't need a special case for methods like with the `__guardMethod__` stuff. There's some duplicated code, but a lot of helper methods have been shared and there are enough differences that it seems reasonable to have the duplication for now and try to consolidate later if it becomes a bigger issue.
alangpierce
added a commit
that referenced
this issue
Feb 19, 2017
Fixes #801 Progress toward #336 We now use a conditional for soaked dynamic member access and soaked function calls as long as the expression is repeatable and does not contain any soak operations. This is pretty much the same strategy as for soaked member accesses. For function calls, the code naturally becomes method call syntax when necessary, so we don't need a special case for methods like with the `__guardMethod__` stuff. There's some duplicated code, but a lot of helper methods have been shared and there are enough differences that it seems reasonable to have the duplication for now and try to consolidate later if it becomes a bigger issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
decaffeinate is producing the wrong JavaScript based on my CoffeeScript input:
(repl)
I get this output:
Here's what I expect it to be instead:
I think that this only happens with identifiers, and identifiers are always repeatable, so it should be reasonable to skip the
__guard__
call in this case.https://github.com/clutchski/coffeelint/blob/master/src/cache.coffee#L6
The text was updated successfully, but these errors were encountered: