From f82c3aef48e44f397a51b7d4ad7cb4e54b2725d9 Mon Sep 17 00:00:00 2001 From: Lars Melchior Date: Sat, 26 Jan 2019 13:17:23 +0100 Subject: [PATCH 1/2] fix-lua-identifier --- src/TSHelper.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TSHelper.ts b/src/TSHelper.ts index f606fb341..89e57f575 100644 --- a/src/TSHelper.ts +++ b/src/TSHelper.ts @@ -514,7 +514,8 @@ export class TSHelper { } public static isValidLuaIdentifier(str: string): boolean { - return str.match(/[a-zA-Z_][a-zA-Z0-9_]*/) !== null; + const match = str.match(/[a-zA-Z_][a-zA-Z0-9_]*/); + return match && match[0] === str; } public static isFalsible(type: ts.Type, strictNullChecks: boolean): boolean { From 00da00b2676a4c8e40b6057dce399a1e57c069d3 Mon Sep 17 00:00:00 2001 From: Lars Melchior Date: Sat, 26 Jan 2019 13:27:48 +0100 Subject: [PATCH 2/2] added test --- test/unit/assignments.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unit/assignments.spec.ts b/test/unit/assignments.spec.ts index badd03262..94034ab25 100644 --- a/test/unit/assignments.spec.ts +++ b/test/unit/assignments.spec.ts @@ -803,4 +803,14 @@ export class AssignmentTests { "Unsupported assignment of mixed function/method overload. " + "Overloads should either be all functions or all methods, but not both."); } + + @Test("String table access") + public stringTableAccess(assignType: string): void { + const code = `const dict : {[key:string]:any} = {}; + dict["a b"] = 3; + return dict["a b"];`; + const result = util.transpileAndExecute(code); + Expect(result).toBe(3); + } + }