diff --git a/tsc/internal/parser/parser.go b/tsc/internal/parser/parser.go index c670d64ad21c2..e37c5b193fb6a 100644 --- a/tsc/internal/parser/parser.go +++ b/tsc/internal/parser/parser.go @@ -4691,6 +4691,9 @@ func (p *Parser) parseBinaryExpressionRest(precedence ast.OperatorPrecedence, le if !shouldConsumeBinaryOperator(operator, newPrecedence, precedence) { break } + if p.hasPrecedingLineBreak() && (p.scanner.HasUnicodeEscape() || p.scanner.HasExtendedUnicodeEscape()) && ast.NodeIsPresent(leftOperand) { + break + } if operator == ast.KindInKeyword && p.inDisallowInContext() { break } diff --git a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.errors.txt b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.errors.txt index 3f909bf206319..4c75c99a59b0d 100644 --- a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.errors.txt +++ b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.errors.txt @@ -1,3 +1,9 @@ +c.ts(3,15): error TS1260: Keywords cannot contain escape characters. +c.ts(4,14): error TS1260: Keywords cannot contain escape characters. +d.js(3,15): error TS1260: Keywords cannot contain escape characters. +d.js(4,14): error TS1260: Keywords cannot contain escape characters. +e.ts(5,9): error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression +f.js(5,9): error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression file1.ts(3,5): error TS1260: Keywords cannot contain escape characters. file1.ts(8,5): error TS1260: Keywords cannot contain escape characters. file1.ts(13,1): error TS1260: Keywords cannot contain escape characters. @@ -5,6 +11,16 @@ file2.ts(1,1): error TS1260: Keywords cannot contain escape characters. file2.ts(5,5): error TS1260: Keywords cannot contain escape characters. file2.ts(10,5): error TS1260: Keywords cannot contain escape characters. file2.ts(15,1): error TS1260: Keywords cannot contain escape characters. +g.ts(3,1): error TS1109: Expression expected. +g.ts(3,8): error TS1109: Expression expected. +h.ts(3,1): error TS1109: Expression expected. +i.ts(3,5): error TS1005: ')' expected. +i.ts(3,14): error TS1005: ';' expected. +j.js(3,1): error TS1109: Expression expected. +j.js(3,8): error TS1109: Expression expected. +k.js(3,1): error TS1109: Expression expected. +l.js(3,5): error TS1005: ')' expected. +l.js(3,14): error TS1005: ';' expected. ==== file1.ts (3 errors) ==== @@ -58,4 +74,194 @@ file2.ts(15,1): error TS1260: Keywords cannot contain escape characters. const a = {def\u0061ult: 12}; // OK, `default` not in keyword position // chrome and jsc may still error on this, ref https://bugs.chromium.org/p/chromium/issues/detail?id=993000 and https://bugs.webkit.org/show_bug.cgi?id=200638 + +==== a.ts (0 errors) ==== + export {}; + + class A { + a = 1 + \u{69}n + b = 2 + \u{69}nstanceof + } + + class B { + a = 1 + \u0069n + b = 2 + \u0069nstanceof + } + + class C { + a = () => 1 + \u{69}nstanceof + b = 2 + \u0069n() {} + } + + class D { + a = "a" + in + { a: 1 } + b = {} + instanceof + Object + } + + class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; + } + + const a = Object.keys(new A()); + const b = Object.keys(new B()); + const c = new C(); + const d = new D(); + const e = 1; + const f = \u0065 + + 1; + +==== b.js (0 errors) ==== + export {}; + + class A { + a = 1 + \u{69}n + b = 2 + \u{69}nstanceof + } + + class B { + a = 1 + \u0069n + b = 2 + \u0069nstanceof + } + + class C { + a = () => 1 + \u{69}nstanceof + b = 2 + \u0069n() {} + } + + class D { + a = "a" + in + { a: 1 } + b = {} + instanceof + Object + } + + class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; + } + + const a = Object.keys(new A()); + const b = Object.keys(new B()); + const c = new C(); + const d = new D(); + const e = 1; + const f = \u0065 + + 1; + +==== c.ts (2 errors) ==== + export {}; + + const a = "a" \u0069n { a: 1 }; + ~~~~~~~ +!!! error TS1260: Keywords cannot contain escape characters. + const b = {} \u{69}nstanceof Object; + ~~~~~~~~~~~~~~~ +!!! error TS1260: Keywords cannot contain escape characters. + +==== d.js (2 errors) ==== + export {}; + + const a = "a" \u0069n { a: 1 }; + ~~~~~~~ +!!! error TS1260: Keywords cannot contain escape characters. + const b = {} \u{69}nstanceof Object; + ~~~~~~~~~~~~~~~ +!!! error TS1260: Keywords cannot contain escape characters. + +==== e.ts (1 errors) ==== + export {}; + + class A { + #a; + b = #a + ~~ +!!! error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression + \u0069n + } + +==== f.js (1 errors) ==== + export {}; + + class A { + #a; + b = #a + ~~ +!!! error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression + \u0069n + } + +==== g.ts (2 errors) ==== + declare var x: any, y: any; + x + \u0069n + ~~~~~~~ +!!! error TS1109: Expression expected. + +!!! error TS1109: Expression expected. + +==== h.ts (1 errors) ==== + declare var x: any, y: any; + x + \u{69}nstanceof y + ~~~~~~~~~~~~~~~ +!!! error TS1109: Expression expected. + +==== i.ts (2 errors) ==== + declare var x: any, y: any; + if (x + \u0069n y) {} + ~~~~~~~ +!!! error TS1005: ')' expected. +!!! related TS1007 i.ts:2:4: The parser expected to find a ')' to match the '(' token here. + ~ +!!! error TS1005: ';' expected. + +==== j.js (2 errors) ==== + var x, y; + x + \u0069n + ~~~~~~~ +!!! error TS1109: Expression expected. + +!!! error TS1109: Expression expected. + +==== k.js (1 errors) ==== + var x, y; + x + \u{69}nstanceof y + ~~~~~~~~~~~~~~~ +!!! error TS1109: Expression expected. + +==== l.js (2 errors) ==== + var x, y; + if (x + \u0069n y) {} + ~~~~~~~ +!!! error TS1005: ')' expected. +!!! related TS1007 l.js:2:4: The parser expected to find a ')' to match the '(' token here. + ~ +!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.js b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.js index eda3976c557f1..59ed814299d5e 100644 --- a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.js +++ b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.js @@ -38,6 +38,162 @@ export {}; const a = {def\u0061ult: 12}; // OK, `default` not in keyword position // chrome and jsc may still error on this, ref https://bugs.chromium.org/p/chromium/issues/detail?id=993000 and https://bugs.webkit.org/show_bug.cgi?id=200638 +//// [a.ts] +export {}; + +class A { + a = 1 + \u{69}n + b = 2 + \u{69}nstanceof +} + +class B { + a = 1 + \u0069n + b = 2 + \u0069nstanceof +} + +class C { + a = () => 1 + \u{69}nstanceof + b = 2 + \u0069n() {} +} + +class D { + a = "a" + in + { a: 1 } + b = {} + instanceof + Object +} + +class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; +} + +const a = Object.keys(new A()); +const b = Object.keys(new B()); +const c = new C(); +const d = new D(); +const e = 1; +const f = \u0065 + + 1; + +//// [b.js] +export {}; + +class A { + a = 1 + \u{69}n + b = 2 + \u{69}nstanceof +} + +class B { + a = 1 + \u0069n + b = 2 + \u0069nstanceof +} + +class C { + a = () => 1 + \u{69}nstanceof + b = 2 + \u0069n() {} +} + +class D { + a = "a" + in + { a: 1 } + b = {} + instanceof + Object +} + +class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; +} + +const a = Object.keys(new A()); +const b = Object.keys(new B()); +const c = new C(); +const d = new D(); +const e = 1; +const f = \u0065 + + 1; + +//// [c.ts] +export {}; + +const a = "a" \u0069n { a: 1 }; +const b = {} \u{69}nstanceof Object; + +//// [d.js] +export {}; + +const a = "a" \u0069n { a: 1 }; +const b = {} \u{69}nstanceof Object; + +//// [e.ts] +export {}; + +class A { + #a; + b = #a + \u0069n +} + +//// [f.js] +export {}; + +class A { + #a; + b = #a + \u0069n +} + +//// [g.ts] +declare var x: any, y: any; +x +\u0069n + +//// [h.ts] +declare var x: any, y: any; +x +\u{69}nstanceof y + +//// [i.ts] +declare var x: any, y: any; +if (x + \u0069n y) {} + +//// [j.js] +var x, y; +x +\u0069n + +//// [k.js] +var x, y; +x +\u{69}nstanceof y + +//// [l.js] +var x, y; +if (x + \u0069n y) {} + //// [file1.js] var \u0061wait = 12; // ok @@ -62,3 +218,138 @@ function* gen() { const a = { def\u0061ult: 12 }; // OK, `default` not in keyword position export {}; // chrome and jsc may still error on this, ref https://bugs.chromium.org/p/chromium/issues/detail?id=993000 and https://bugs.webkit.org/show_bug.cgi?id=200638 +//// [a.js] +class A { + a = 1; + \u{69}n; + b = 2; + \u{69}nstanceof; +} +class B { + a = 1; + \u0069n; + b = 2; + \u0069nstanceof; +} +class C { + a = () => 1; + \u{69}nstanceof; + b = 2; + \u0069n() { } +} +class D { + a = "a" + in + { a: 1 }; + b = {} + instanceof + Object; +} +class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; +} +const a = Object.keys(new A()); +const b = Object.keys(new B()); +const c = new C(); +const d = new D(); +const e = 1; +const f = \u0065 + + 1; +export {}; +//// [b.js] +export {}; +class A { + a = 1; + \u{69}n; + b = 2; + \u{69}nstanceof; +} +class B { + a = 1; + \u0069n; + b = 2; + \u0069nstanceof; +} +class C { + a = () => 1; + \u{69}nstanceof; + b = 2; + \u0069n() { } +} +class D { + a = "a" + in + { a: 1 }; + b = {} + instanceof + Object; +} +class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; +} +const a = Object.keys(new A()); +const b = Object.keys(new B()); +const c = new C(); +const d = new D(); +const e = 1; +const f = \u0065 + + 1; +//// [c.js] +const a = "a" in { a: 1 }; +const b = {} instanceof Object; +export {}; +//// [d.js] +export {}; +const a = "a" in { a: 1 }; +const b = {} instanceof Object; +//// [e.js] +class A { + #a; + b = #a; + \u0069n; +} +export {}; +//// [f.js] +export {}; +class A { + #a; + b = #a; + \u0069n; +} +//// [g.js] +"use strict"; +x; + in +; +//// [h.js] +"use strict"; +x; + instanceof y; +//// [i.js] +"use strict"; +if (x) + in y; +{ } +//// [j.js] +"use strict"; +var x, y; +x; + in +; +//// [k.js] +"use strict"; +var x, y; +x; + instanceof y; +//// [l.js] +"use strict"; +var x, y; +if (x) + in y; +{ } diff --git a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.symbols b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.symbols index 7c4b7f2af98b7..1ad704232f24c 100644 --- a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.symbols +++ b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.symbols @@ -62,3 +62,353 @@ const a = {def\u0061ult: 12}; // OK, `default` not in keyword position // chrome and jsc may still error on this, ref https://bugs.chromium.org/p/chromium/issues/detail?id=993000 and https://bugs.webkit.org/show_bug.cgi?id=200638 +=== a.ts === +export {}; + +class A { +>A : Symbol(A, Decl(a.ts, 0, 10)) + + a = 1 +>a : Symbol(A.a, Decl(a.ts, 2, 9)) + + \u{69}n +>\u{69}n : Symbol(A[\u{69}n], Decl(a.ts, 3, 9)) + + b = 2 +>b : Symbol(A.b, Decl(a.ts, 4, 11)) + + \u{69}nstanceof +>\u{69}nstanceof : Symbol(A[\u{69}nstanceof], Decl(a.ts, 5, 9)) +} + +class B { +>B : Symbol(B, Decl(a.ts, 7, 1)) + + a = 1 +>a : Symbol(B.a, Decl(a.ts, 9, 9)) + + \u0069n +>\u0069n : Symbol(B[\u0069n], Decl(a.ts, 10, 9)) + + b = 2 +>b : Symbol(B.b, Decl(a.ts, 11, 11)) + + \u0069nstanceof +>\u0069nstanceof : Symbol(B[\u0069nstanceof], Decl(a.ts, 12, 9)) +} + +class C { +>C : Symbol(C, Decl(a.ts, 14, 1)) + + a = () => 1 +>a : Symbol(C.a, Decl(a.ts, 16, 9)) + + \u{69}nstanceof +>\u{69}nstanceof : Symbol(C[\u{69}nstanceof], Decl(a.ts, 17, 15)) + + b = 2 +>b : Symbol(C.b, Decl(a.ts, 18, 19)) + + \u0069n() {} +>\u0069n : Symbol(C[\u0069n], Decl(a.ts, 19, 9)) +} + +class D { +>D : Symbol(D, Decl(a.ts, 21, 1)) + + a = "a" +>a : Symbol(D.a, Decl(a.ts, 23, 9)) + + in + { a: 1 } +>a : Symbol(a, Decl(a.ts, 26, 5)) + + b = {} +>b : Symbol(D.b, Decl(a.ts, 26, 12)) + + instanceof + Object +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +class E { +>E : Symbol(E, Decl(a.ts, 30, 1)) + + a = 1; +>a : Symbol(E.a, Decl(a.ts, 32, 9)) + + \u0069n = 2; +>\u0069n : Symbol(E[\u0069n], Decl(a.ts, 33, 10)) + + b = 3; +>b : Symbol(E.b, Decl(a.ts, 34, 16)) + + \u{69}nstanceof = 4; +>\u{69}nstanceof : Symbol(E[\u{69}nstanceof], Decl(a.ts, 35, 10)) +} + +const a = Object.keys(new A()); +>a : Symbol(a, Decl(a.ts, 39, 5)) +>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>A : Symbol(A, Decl(a.ts, 0, 10)) + +const b = Object.keys(new B()); +>b : Symbol(b, Decl(a.ts, 40, 5)) +>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>B : Symbol(B, Decl(a.ts, 7, 1)) + +const c = new C(); +>c : Symbol(c, Decl(a.ts, 41, 5)) +>C : Symbol(C, Decl(a.ts, 14, 1)) + +const d = new D(); +>d : Symbol(d, Decl(a.ts, 42, 5)) +>D : Symbol(D, Decl(a.ts, 21, 1)) + +const e = 1; +>e : Symbol(e, Decl(a.ts, 43, 5)) + +const f = \u0065 +>f : Symbol(f, Decl(a.ts, 44, 5)) +>\u0065 : Symbol(e, Decl(a.ts, 43, 5)) + + + 1; + +=== b.js === +export {}; + +class A { +>A : Symbol(A, Decl(b.js, 0, 10)) + + a = 1 +>a : Symbol(A.a, Decl(b.js, 2, 9)) + + \u{69}n +>\u{69}n : Symbol(A[\u{69}n], Decl(b.js, 3, 9)) + + b = 2 +>b : Symbol(A.b, Decl(b.js, 4, 11)) + + \u{69}nstanceof +>\u{69}nstanceof : Symbol(A[\u{69}nstanceof], Decl(b.js, 5, 9)) +} + +class B { +>B : Symbol(B, Decl(b.js, 7, 1)) + + a = 1 +>a : Symbol(B.a, Decl(b.js, 9, 9)) + + \u0069n +>\u0069n : Symbol(B[\u0069n], Decl(b.js, 10, 9)) + + b = 2 +>b : Symbol(B.b, Decl(b.js, 11, 11)) + + \u0069nstanceof +>\u0069nstanceof : Symbol(B[\u0069nstanceof], Decl(b.js, 12, 9)) +} + +class C { +>C : Symbol(C, Decl(b.js, 14, 1)) + + a = () => 1 +>a : Symbol(C.a, Decl(b.js, 16, 9)) + + \u{69}nstanceof +>\u{69}nstanceof : Symbol(C[\u{69}nstanceof], Decl(b.js, 17, 15)) + + b = 2 +>b : Symbol(C.b, Decl(b.js, 18, 19)) + + \u0069n() {} +>\u0069n : Symbol(C[\u0069n], Decl(b.js, 19, 9)) +} + +class D { +>D : Symbol(D, Decl(b.js, 21, 1)) + + a = "a" +>a : Symbol(D.a, Decl(b.js, 23, 9)) + + in + { a: 1 } +>a : Symbol(a, Decl(b.js, 26, 5)) + + b = {} +>b : Symbol(D.b, Decl(b.js, 26, 12)) + + instanceof + Object +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +class E { +>E : Symbol(E, Decl(b.js, 30, 1)) + + a = 1; +>a : Symbol(E.a, Decl(b.js, 32, 9)) + + \u0069n = 2; +>\u0069n : Symbol(E[\u0069n], Decl(b.js, 33, 10)) + + b = 3; +>b : Symbol(E.b, Decl(b.js, 34, 16)) + + \u{69}nstanceof = 4; +>\u{69}nstanceof : Symbol(E[\u{69}nstanceof], Decl(b.js, 35, 10)) +} + +const a = Object.keys(new A()); +>a : Symbol(a, Decl(b.js, 39, 5)) +>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>A : Symbol(A, Decl(b.js, 0, 10)) + +const b = Object.keys(new B()); +>b : Symbol(b, Decl(b.js, 40, 5)) +>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>B : Symbol(B, Decl(b.js, 7, 1)) + +const c = new C(); +>c : Symbol(c, Decl(b.js, 41, 5)) +>C : Symbol(C, Decl(b.js, 14, 1)) + +const d = new D(); +>d : Symbol(d, Decl(b.js, 42, 5)) +>D : Symbol(D, Decl(b.js, 21, 1)) + +const e = 1; +>e : Symbol(e, Decl(b.js, 43, 5)) + +const f = \u0065 +>f : Symbol(f, Decl(b.js, 44, 5)) +>\u0065 : Symbol(e, Decl(b.js, 43, 5)) + + + 1; + +=== c.ts === +export {}; + +const a = "a" \u0069n { a: 1 }; +>a : Symbol(a, Decl(c.ts, 2, 5)) +>a : Symbol(a, Decl(c.ts, 2, 23)) + +const b = {} \u{69}nstanceof Object; +>b : Symbol(b, Decl(c.ts, 3, 5)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +=== d.js === +export {}; + +const a = "a" \u0069n { a: 1 }; +>a : Symbol(a, Decl(d.js, 2, 5)) +>a : Symbol(a, Decl(d.js, 2, 23)) + +const b = {} \u{69}nstanceof Object; +>b : Symbol(b, Decl(d.js, 3, 5)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +=== e.ts === +export {}; + +class A { +>A : Symbol(A, Decl(e.ts, 0, 10)) + + #a; +>#a : Symbol(A.#a, Decl(e.ts, 2, 9)) + + b = #a +>b : Symbol(A.b, Decl(e.ts, 3, 7)) + + \u0069n +>\u0069n : Symbol(A[\u0069n], Decl(e.ts, 4, 10)) +} + +=== f.js === +export {}; + +class A { +>A : Symbol(A, Decl(f.js, 0, 10)) + + #a; +>#a : Symbol(A.#a, Decl(f.js, 2, 9)) + + b = #a +>b : Symbol(A.b, Decl(f.js, 3, 7)) + + \u0069n +>\u0069n : Symbol(A[\u0069n], Decl(f.js, 4, 10)) +} + +=== g.ts === +declare var x: any, y: any; +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +x +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) + +\u0069n + +=== h.ts === +declare var x: any, y: any; +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +x +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) + +\u{69}nstanceof y +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +=== i.ts === +declare var x: any, y: any; +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +if (x +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) + + \u0069n y) {} +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +=== j.js === +var x, y; +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +x +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) + +\u0069n + +=== k.js === +var x, y; +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +x +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) + +\u{69}nstanceof y +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +=== l.js === +var x, y; +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + +if (x +>x : Symbol(x, Decl(g.ts, 0, 11), Decl(h.ts, 0, 11), Decl(i.ts, 0, 11), Decl(j.js, 0, 3), Decl(k.js, 0, 3) ... and 1 more) + + \u0069n y) {} +>y : Symbol(y, Decl(g.ts, 0, 19), Decl(h.ts, 0, 19), Decl(i.ts, 0, 19), Decl(j.js, 0, 6), Decl(k.js, 0, 6) ... and 1 more) + diff --git a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.types b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.types index 88b9de35e8ab7..0f612f9089224 100644 --- a/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.types +++ b/tsc/testdata/baselines/reference/conformance/scannerUnicodeEscapeInKeyword2.types @@ -77,3 +77,433 @@ const a = {def\u0061ult: 12}; // OK, `default` not in keyword position // chrome and jsc may still error on this, ref https://bugs.chromium.org/p/chromium/issues/detail?id=993000 and https://bugs.webkit.org/show_bug.cgi?id=200638 +=== a.ts === +export {}; + +class A { +>A : A + + a = 1 +>a : number +>1 : 1 + + \u{69}n +>\u{69}n : any + + b = 2 +>b : number +>2 : 2 + + \u{69}nstanceof +>\u{69}nstanceof : any +} + +class B { +>B : B + + a = 1 +>a : number +>1 : 1 + + \u0069n +>\u0069n : any + + b = 2 +>b : number +>2 : 2 + + \u0069nstanceof +>\u0069nstanceof : any +} + +class C { +>C : C + + a = () => 1 +>a : () => number +>() => 1 : () => number +>1 : 1 + + \u{69}nstanceof +>\u{69}nstanceof : any + + b = 2 +>b : number +>2 : 2 + + \u0069n() {} +>\u0069n : () => void +} + +class D { +>D : D + + a = "a" +>a : boolean +>"a" in { a: 1 } : boolean +>"a" : "a" + + in + { a: 1 } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + + b = {} +>b : boolean +>{} instanceof Object : boolean +>{} : {} + + instanceof + Object +>Object : ObjectConstructor +} + +class E { +>E : E + + a = 1; +>a : number +>1 : 1 + + \u0069n = 2; +>\u0069n : number +>2 : 2 + + b = 3; +>b : number +>3 : 3 + + \u{69}nstanceof = 4; +>\u{69}nstanceof : number +>4 : 4 +} + +const a = Object.keys(new A()); +>a : string[] +>Object.keys(new A()) : string[] +>Object.keys : { (o: object): string[]; (o: {}): string[]; } +>Object : ObjectConstructor +>keys : { (o: object): string[]; (o: {}): string[]; } +>new A() : A +>A : typeof A + +const b = Object.keys(new B()); +>b : string[] +>Object.keys(new B()) : string[] +>Object.keys : { (o: object): string[]; (o: {}): string[]; } +>Object : ObjectConstructor +>keys : { (o: object): string[]; (o: {}): string[]; } +>new B() : B +>B : typeof B + +const c = new C(); +>c : C +>new C() : C +>C : typeof C + +const d = new D(); +>d : D +>new D() : D +>D : typeof D + +const e = 1; +>e : 1 +>1 : 1 + +const f = \u0065 +>f : number +>\u0065 + 1 : number +>\u0065 : 1 + + + 1; +>1 : 1 + +=== b.js === +export {}; + +class A { +>A : A + + a = 1 +>a : number +>1 : 1 + + \u{69}n +>\u{69}n : any + + b = 2 +>b : number +>2 : 2 + + \u{69}nstanceof +>\u{69}nstanceof : any +} + +class B { +>B : B + + a = 1 +>a : number +>1 : 1 + + \u0069n +>\u0069n : any + + b = 2 +>b : number +>2 : 2 + + \u0069nstanceof +>\u0069nstanceof : any +} + +class C { +>C : C + + a = () => 1 +>a : () => number +>() => 1 : () => number +>1 : 1 + + \u{69}nstanceof +>\u{69}nstanceof : any + + b = 2 +>b : number +>2 : 2 + + \u0069n() {} +>\u0069n : () => void +} + +class D { +>D : D + + a = "a" +>a : boolean +>"a" in { a: 1 } : boolean +>"a" : "a" + + in + { a: 1 } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + + b = {} +>b : boolean +>{} instanceof Object : boolean +>{} : {} + + instanceof + Object +>Object : ObjectConstructor +} + +class E { +>E : E + + a = 1; +>a : number +>1 : 1 + + \u0069n = 2; +>\u0069n : number +>2 : 2 + + b = 3; +>b : number +>3 : 3 + + \u{69}nstanceof = 4; +>\u{69}nstanceof : number +>4 : 4 +} + +const a = Object.keys(new A()); +>a : string[] +>Object.keys(new A()) : string[] +>Object.keys : { (o: object): string[]; (o: {}): string[]; } +>Object : ObjectConstructor +>keys : { (o: object): string[]; (o: {}): string[]; } +>new A() : A +>A : typeof A + +const b = Object.keys(new B()); +>b : string[] +>Object.keys(new B()) : string[] +>Object.keys : { (o: object): string[]; (o: {}): string[]; } +>Object : ObjectConstructor +>keys : { (o: object): string[]; (o: {}): string[]; } +>new B() : B +>B : typeof B + +const c = new C(); +>c : C +>new C() : C +>C : typeof C + +const d = new D(); +>d : D +>new D() : D +>D : typeof D + +const e = 1; +>e : 1 +>1 : 1 + +const f = \u0065 +>f : number +>\u0065 + 1 : number +>\u0065 : 1 + + + 1; +>1 : 1 + +=== c.ts === +export {}; + +const a = "a" \u0069n { a: 1 }; +>a : boolean +>"a" \u0069n { a: 1 } : boolean +>"a" : "a" +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + +const b = {} \u{69}nstanceof Object; +>b : boolean +>{} \u{69}nstanceof Object : boolean +>{} : {} +>Object : ObjectConstructor + +=== d.js === +export {}; + +const a = "a" \u0069n { a: 1 }; +>a : boolean +>"a" \u0069n { a: 1 } : boolean +>"a" : "a" +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + +const b = {} \u{69}nstanceof Object; +>b : boolean +>{} \u{69}nstanceof Object : boolean +>{} : {} +>Object : ObjectConstructor + +=== e.ts === +export {}; + +class A { +>A : A + + #a; +>#a : any + + b = #a +>b : any + + \u0069n +>\u0069n : any +} + +=== f.js === +export {}; + +class A { +>A : A + + #a; +>#a : any + + b = #a +>b : any + + \u0069n +>\u0069n : any +} + +=== g.ts === +declare var x: any, y: any; +>x : any +>y : any + +x +>x : any + +\u0069n +>\u0069n : boolean +> : any + +> : any + +=== h.ts === +declare var x: any, y: any; +>x : any +>y : any + +x +>x : any + +\u{69}nstanceof y +>\u{69}nstanceof y : boolean +> : any +>y : any + +=== i.ts === +declare var x: any, y: any; +>x : any +>y : any + +if (x +>x : any + + \u0069n y) {} +>\u0069n y : boolean +> : any +>y : any + +=== j.js === +var x, y; +>x : any +>y : any + +x +>x : any + +\u0069n +>\u0069n : boolean +> : any + +> : any + +=== k.js === +var x, y; +>x : any +>y : any + +x +>x : any + +\u{69}nstanceof y +>\u{69}nstanceof y : boolean +> : any +>y : any + +=== l.js === +var x, y; +>x : any +>y : any + +if (x +>x : any + + \u0069n y) {} +>\u0069n y : boolean +> : any +>y : any + diff --git a/tsc/testdata/tests/cases/conformance/scanner/ecmascript5/scannerUnicodeEscapeInKeyword2.ts b/tsc/testdata/tests/cases/conformance/scanner/ecmascript5/scannerUnicodeEscapeInKeyword2.ts index a92c22569dba2..37458fab26a1a 100644 --- a/tsc/testdata/tests/cases/conformance/scanner/ecmascript5/scannerUnicodeEscapeInKeyword2.ts +++ b/tsc/testdata/tests/cases/conformance/scanner/ecmascript5/scannerUnicodeEscapeInKeyword2.ts @@ -1,4 +1,7 @@ // @target: esnext +// @noImplicitAny: false +// @checkJs: true +// @outDir: out // @filename: file1.ts var \u0061wait = 12; // ok async function main() { @@ -37,3 +40,159 @@ export {}; const a = {def\u0061ult: 12}; // OK, `default` not in keyword position // chrome and jsc may still error on this, ref https://bugs.chromium.org/p/chromium/issues/detail?id=993000 and https://bugs.webkit.org/show_bug.cgi?id=200638 + +// @filename: a.ts +export {}; + +class A { + a = 1 + \u{69}n + b = 2 + \u{69}nstanceof +} + +class B { + a = 1 + \u0069n + b = 2 + \u0069nstanceof +} + +class C { + a = () => 1 + \u{69}nstanceof + b = 2 + \u0069n() {} +} + +class D { + a = "a" + in + { a: 1 } + b = {} + instanceof + Object +} + +class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; +} + +const a = Object.keys(new A()); +const b = Object.keys(new B()); +const c = new C(); +const d = new D(); +const e = 1; +const f = \u0065 + + 1; + +// @filename: b.js +export {}; + +class A { + a = 1 + \u{69}n + b = 2 + \u{69}nstanceof +} + +class B { + a = 1 + \u0069n + b = 2 + \u0069nstanceof +} + +class C { + a = () => 1 + \u{69}nstanceof + b = 2 + \u0069n() {} +} + +class D { + a = "a" + in + { a: 1 } + b = {} + instanceof + Object +} + +class E { + a = 1; + \u0069n = 2; + b = 3; + \u{69}nstanceof = 4; +} + +const a = Object.keys(new A()); +const b = Object.keys(new B()); +const c = new C(); +const d = new D(); +const e = 1; +const f = \u0065 + + 1; + +// @filename: c.ts +export {}; + +const a = "a" \u0069n { a: 1 }; +const b = {} \u{69}nstanceof Object; + +// @filename: d.js +export {}; + +const a = "a" \u0069n { a: 1 }; +const b = {} \u{69}nstanceof Object; + +// @filename: e.ts +export {}; + +class A { + #a; + b = #a + \u0069n +} + +// @filename: f.js +export {}; + +class A { + #a; + b = #a + \u0069n +} + +// @filename: g.ts +declare var x: any, y: any; +x +\u0069n + +// @filename: h.ts +declare var x: any, y: any; +x +\u{69}nstanceof y + +// @filename: i.ts +declare var x: any, y: any; +if (x + \u0069n y) {} + +// @filename: j.js +var x, y; +x +\u0069n + +// @filename: k.js +var x, y; +x +\u{69}nstanceof y + +// @filename: l.js +var x, y; +if (x + \u0069n y) {}