-
Notifications
You must be signed in to change notification settings - Fork 120
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorrect arguments by default with this
#1360
Comments
It works good w/o the curly braces
|
Idea to workaround:
|
Another bad cases: class Component
foo: (a,{b=@b}, c) ->
42 class Component {
foo(a,{b=b1}, c) {
this.b = b1;
return 42;
}
} |
This definitely appears to be a bug. Here's a minimal reproduction: ({ a = @a }) -> (function({ a = a1 }) {
this.a = a1;
}); I think the problem is that it's inspecting the whole subtree of nodes for default values to assign, when it shouldn't be doing so with the right hand side of the assignment. I don't know that's the case, but that's what it feels like. I'd be happy to review a PR to fix this. |
has you any beginner's contributor guide? |
I tried to patch it and crashed into partially broken TS source maps in the node --inspector and long manual rebuilding (what about adding wath build? I tried, it's not so easy) |
Have you looked at this? https://github.com/decaffeinate/decaffeinate/blob/master/docs/contribution-guide.md |
I was able to fix this case, sort of, by using this: diff --git a/src/stages/normalize/patchers/MemberAccessOpPatcher.ts b/src/stages/normalize/patchers/MemberAccessOpPatcher.ts
index ea944d0d..f1dccf3c 100644
--- a/src/stages/normalize/patchers/MemberAccessOpPatcher.ts
+++ b/src/stages/normalize/patchers/MemberAccessOpPatcher.ts
@@ -4,6 +4,7 @@ import PassthroughPatcher from '../../../patchers/PassthroughPatcher';
import { PatcherContext } from '../../../patchers/types';
import DefaultParamPatcher from './DefaultParamPatcher';
import IdentifierPatcher from './IdentifierPatcher';
+import AssignOpPatcher from './AssignOpPatcher';
export default class MemberAccessOpPatcher extends PassthroughPatcher {
node: MemberAccessOp;
@@ -41,6 +42,9 @@ export default class MemberAccessOpPatcher extends PassthroughPatcher {
if (patcher.parent instanceof DefaultParamPatcher && patcher.parent.value === patcher) {
break;
}
+ if (patcher.parent instanceof AssignOpPatcher && patcher.parent.expression === patcher) {
+ break;
+ }
patcher = patcher.parent;
}
return null; However, that breaks some other cases. We want both of these to work, but I'm not sure how to make that happen: it('handles destructured param with `this` member access default value (#1360)', () =>
checkCS2(
`
({ a = @a }) ->
`,
`
(function({ a = this.a }) {});
`
));
it('handles destructured param with default value (#1360)', () =>
checkCS2(
`
({ a } = {}) ->`,
`
(function({ a } = {}) {});
`
)); |
饾摥饾摦饾摤饾摢饾摨饾摨饾摦饾摬饾摲饾摢饾摻饾摦 is incorrectly transpiling my CoffeeScript input:
source
REPL
incorrect result (indentation issue is there too):
expected:
The text was updated successfully, but these errors were encountered: