-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use
Constructor
node even for external constructors (#163)
Progress toward #830 Constructors are allowed to be arbitrary expressions in CoffeeScript, so I think the right approach is for the parser to use the `Constructor` node even if the value isn't a function, and decaffeinate will figure out the right way to handle it.
- Loading branch information
1 parent
3c4f328
commit c28a27a
Showing
4 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
f = -> | ||
class A | ||
constructor: f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
{ | ||
"type": "Program", | ||
"line": 1, | ||
"column": 1, | ||
"range": [ | ||
0, | ||
32 | ||
], | ||
"raw": "f = ->\nclass A\n constructor: f\n", | ||
"body": { | ||
"type": "Block", | ||
"line": 1, | ||
"column": 1, | ||
"range": [ | ||
0, | ||
31 | ||
], | ||
"statements": [ | ||
{ | ||
"type": "AssignOp", | ||
"line": 1, | ||
"column": 1, | ||
"range": [ | ||
0, | ||
6 | ||
], | ||
"assignee": { | ||
"type": "Identifier", | ||
"line": 1, | ||
"column": 1, | ||
"raw": "f", | ||
"range": [ | ||
0, | ||
1 | ||
], | ||
"data": "f" | ||
}, | ||
"expression": { | ||
"type": "Function", | ||
"line": 1, | ||
"column": 5, | ||
"range": [ | ||
4, | ||
6 | ||
], | ||
"body": null, | ||
"parameters": [], | ||
"raw": "->" | ||
}, | ||
"raw": "f = ->" | ||
}, | ||
{ | ||
"type": "Class", | ||
"line": 2, | ||
"column": 1, | ||
"range": [ | ||
7, | ||
31 | ||
], | ||
"name": { | ||
"type": "Identifier", | ||
"line": 2, | ||
"column": 7, | ||
"raw": "A", | ||
"range": [ | ||
13, | ||
14 | ||
], | ||
"data": "A" | ||
}, | ||
"nameAssignee": { | ||
"type": "Identifier", | ||
"line": 2, | ||
"column": 7, | ||
"raw": "A", | ||
"range": [ | ||
13, | ||
14 | ||
], | ||
"data": "A" | ||
}, | ||
"body": { | ||
"type": "Block", | ||
"line": 3, | ||
"column": 3, | ||
"range": [ | ||
17, | ||
31 | ||
], | ||
"statements": [ | ||
{ | ||
"type": "Constructor", | ||
"line": 3, | ||
"column": 3, | ||
"range": [ | ||
17, | ||
31 | ||
], | ||
"assignee": { | ||
"type": "Identifier", | ||
"line": 3, | ||
"column": 3, | ||
"raw": "constructor", | ||
"range": [ | ||
17, | ||
28 | ||
], | ||
"data": "constructor" | ||
}, | ||
"expression": { | ||
"type": "Identifier", | ||
"line": 3, | ||
"column": 16, | ||
"raw": "f", | ||
"range": [ | ||
30, | ||
31 | ||
], | ||
"data": "f" | ||
}, | ||
"raw": "constructor: f" | ||
} | ||
], | ||
"inline": false, | ||
"raw": "constructor: f" | ||
}, | ||
"boundMembers": [], | ||
"parent": null, | ||
"ctor": { | ||
"type": "Constructor", | ||
"line": 3, | ||
"column": 3, | ||
"range": [ | ||
17, | ||
31 | ||
], | ||
"assignee": { | ||
"type": "Identifier", | ||
"line": 3, | ||
"column": 3, | ||
"raw": "constructor", | ||
"range": [ | ||
17, | ||
28 | ||
], | ||
"data": "constructor" | ||
}, | ||
"expression": { | ||
"type": "Identifier", | ||
"line": 3, | ||
"column": 16, | ||
"raw": "f", | ||
"range": [ | ||
30, | ||
31 | ||
], | ||
"data": "f" | ||
}, | ||
"raw": "constructor: f" | ||
}, | ||
"raw": "class A\n constructor: f" | ||
} | ||
], | ||
"raw": "f = ->\nclass A\n constructor: f" | ||
} | ||
} |