Casting ambiguous syntax#181
Conversation
src/Transpiler.ts
Outdated
| if (node.initializer) { | ||
| const value = this.transpileExpression(node.initializer); | ||
| return `local ${identifierName} = ${value}\n`; | ||
| return `local ${identifierName} = ${value};\n`; |
There was a problem hiding this comment.
You pushed these too far down, I suggest adding the ';' in the transpileNode function, like you did for ExpressionStatement.
There was a problem hiding this comment.
That was my first approach, but transpileVariableDeclaration returns a newline, so the transpiled code would look like
local a = 0
;
foo()
There was a problem hiding this comment.
I think that's a bug, if removing the \n from transpileVariableDeclaration does not break any (non-whitespace) tests I am fine with you removing it there.
There was a problem hiding this comment.
That new line after variable declaration is definitely unintentional and should be removed.
Perryvw
left a comment
There was a problem hiding this comment.
Looks good! If you merge master into your branch this can be merged as far as I'm considered. You could also add the suggested ;, or we could leave it for a future update.
| let result = ""; | ||
| for (const variableDeclaration of (node.initializer as ts.VariableDeclarationList).declarations) { | ||
| result += this.indent + this.transpileVariableDeclaration(variableDeclaration); | ||
| result += this.indent + this.transpileVariableDeclaration(variableDeclaration) + "\n"; |
There was a problem hiding this comment.
Not really, you know a while will always follow, so there's no ambiguity. I've tried not to add ; where they weren't needed.
…yntax # Conflicts: # test/unit/objectLiteral.spec.ts
|
Merged master and fixed tests |
using extra paranthesis in ts causes code like
dostuff() (self.member):method();calls, which can be ambiguous depending on context. I've added ; at the end of statements to help disambiguate.Closes #191