Skip to content

Commit 42d0a39

Browse files
tomblindPerryvw
authored andcommitted
fixes for last compile errors (#518)
1 parent 7468a20 commit 42d0a39

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/LuaTransformer.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ export class LuaTransformer {
250250

251251
if (statement.exportClause) {
252252
if (statement.exportClause.elements.some(e =>
253-
(e.name && e.name.originalKeywordKind === ts.SyntaxKind.DefaultKeyword)
254-
|| (e.propertyName && e.propertyName.originalKeywordKind === ts.SyntaxKind.DefaultKeyword))
253+
(e.name !== undefined && e.name.originalKeywordKind === ts.SyntaxKind.DefaultKeyword)
254+
|| (e.propertyName !== undefined
255+
&& e.propertyName.originalKeywordKind === ts.SyntaxKind.DefaultKeyword))
255256
) {
256257
throw TSTLErrors.UnsupportedDefaultExport(statement);
257258
}
@@ -4790,17 +4791,20 @@ export class LuaTransformer {
47904791
}
47914792

47924793
for (const [functionSymbolId, functionDefinition] of scope.functionDefinitions) {
4794+
if (functionDefinition.definition === undefined) {
4795+
// TODO
4796+
throw new Error("Expected functionDefinition.definition to be set, but it isn't.");
4797+
}
47934798
const { line, column } = tstl.getOriginalPos(functionDefinition.definition);
4794-
const definitionPos = ts.getPositionOfLineAndCharacter(
4795-
this.currentSourceFile,
4796-
line,
4797-
column);
4798-
if (functionSymbolId !== symbolId // Don't recurse into self
4799-
&& declaration.pos < definitionPos // Ignore functions before symbol declaration
4800-
&& functionDefinition.referencedSymbols.has(symbolId)
4801-
&& this.shouldHoist(functionSymbolId, scope))
4802-
{
4803-
return true;
4799+
if (line !== undefined && column !== undefined) {
4800+
const definitionPos = ts.getPositionOfLineAndCharacter(this.currentSourceFile, line, column);
4801+
if (functionSymbolId !== symbolId // Don't recurse into self
4802+
&& declaration.pos < definitionPos // Ignore functions before symbol declaration
4803+
&& functionDefinition.referencedSymbols.has(symbolId)
4804+
&& this.shouldHoist(functionSymbolId, scope))
4805+
{
4806+
return true;
4807+
}
48044808
}
48054809
}
48064810
}
@@ -4833,6 +4837,10 @@ export class LuaTransformer {
48334837
const hoistedFunctions: Array<tstl.VariableDeclarationStatement | tstl.AssignmentStatement> = [];
48344838
for (const [functionSymbolId, functionDefinition] of scope.functionDefinitions) {
48354839
if (this.shouldHoist(functionSymbolId, scope)) {
4840+
if (functionDefinition.definition === undefined) {
4841+
// TODO
4842+
throw new Error("Expected functionDefinition.definition to be set, but it isn't.");
4843+
}
48364844
const i = result.indexOf(functionDefinition.definition);
48374845
result.splice(i, 1);
48384846
hoistedFunctions.push(functionDefinition.definition);

0 commit comments

Comments
 (0)