Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1668,14 +1668,14 @@ namespace ts {
if (p >= end) {
tokenIsUnterminated = true;
error(Diagnostics.Unterminated_regular_expression_literal);
break;
return token;
}

const ch = text.charCodeAt(p);
if (isLineBreak(ch)) {
tokenIsUnterminated = true;
error(Diagnostics.Unterminated_regular_expression_literal);
break;
return token;
}

if (inEscape) {
Expand Down
2 changes: 1 addition & 1 deletion src/harness/unittests/incrementalParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace ts {
const oldText = ScriptSnapshot.fromString(source);
const newTextAndChange = withInsert(oldText, semicolonIndex, "/");

compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
});

it("Regular expression 2", () => {
Expand Down
11 changes: 10 additions & 1 deletion tests/baselines/reference/jsxParsingError1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
tests/cases/conformance/jsx/file.tsx(11,36): error TS1005: '}' expected.
tests/cases/conformance/jsx/file.tsx(11,44): error TS1003: Identifier expected.
tests/cases/conformance/jsx/file.tsx(11,45): error TS1109: Expression expected.
tests/cases/conformance/jsx/file.tsx(11,46): error TS1161: Unterminated regular expression literal.
tests/cases/conformance/jsx/file.tsx(11,46): error TS1109: Expression expected.
tests/cases/conformance/jsx/file.tsx(11,47): error TS1109: Expression expected.


==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
declare module JSX {
interface Element { }
interface IntrinsicElements {
Expand All @@ -19,6 +22,12 @@ tests/cases/conformance/jsx/file.tsx(11,46): error TS1161: Unterminated regular
!!! error TS1005: '}' expected.
~
!!! error TS1003: Identifier expected.
~
!!! error TS1109: Expression expected.

!!! error TS1161: Unterminated regular expression literal.
~
!!! error TS1109: Expression expected.
~
!!! error TS1109: Expression expected.

2 changes: 1 addition & 1 deletion tests/baselines/reference/jsxParsingError1.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ const elem = <div className={class1, class2}/>;
var class1 = "foo";
var class2 = "bar";
var elem = <div className={class1} class2/>;
/>;;
/ > ;
8 changes: 7 additions & 1 deletion tests/baselines/reference/parser645086_1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_1.ts(1,13): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_1.ts(1,14): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_1.ts(1,14): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_1.ts(1,15): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_1.ts(1,15): error TS1161: Unterminated regular expression literal.


==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_1.ts (3 errors) ====
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_1.ts (5 errors) ====
var v = /[]/]/
~
!!! error TS1005: ',' expected.
~
!!! error TS1109: Expression expected.
~
!!! error TS1134: Variable declaration expected.

!!! error TS1109: Expression expected.

!!! error TS1161: Unterminated regular expression literal.
2 changes: 1 addition & 1 deletion tests/baselines/reference/parser645086_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ var v = /[]/]/

//// [parser645086_1.js]
var v = /[]/;
/;
/ ;
8 changes: 7 additions & 1 deletion tests/baselines/reference/parser645086_2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_2.ts(1,14): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_2.ts(1,15): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_2.ts(1,15): error TS1134: Variable declaration expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_2.ts(1,16): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_2.ts(1,16): error TS1161: Unterminated regular expression literal.


==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_2.ts (3 errors) ====
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser645086_2.ts (5 errors) ====
var v = /[^]/]/
~
!!! error TS1005: ',' expected.
~
!!! error TS1109: Expression expected.
~
!!! error TS1134: Variable declaration expected.

!!! error TS1109: Expression expected.

!!! error TS1161: Unterminated regular expression literal.
2 changes: 1 addition & 1 deletion tests/baselines/reference/parser645086_2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ var v = /[^]/]/

//// [parser645086_2.js]
var v = /[^]/;
/;
/ ;
10 changes: 8 additions & 2 deletions tests/baselines/reference/parserMissingToken2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
tests/cases/conformance/parser/ecmascript5/MissingTokens/parserMissingToken2.ts(1,1): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript5/MissingTokens/parserMissingToken2.ts(1,2): error TS1161: Unterminated regular expression literal.
tests/cases/conformance/parser/ecmascript5/MissingTokens/parserMissingToken2.ts(1,3): error TS2304: Cannot find name 'b'.


==== tests/cases/conformance/parser/ecmascript5/MissingTokens/parserMissingToken2.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/MissingTokens/parserMissingToken2.ts (3 errors) ====
/ b;
~
!!! error TS1109: Expression expected.

!!! error TS1161: Unterminated regular expression literal.
!!! error TS1161: Unterminated regular expression literal.
~
!!! error TS2304: Cannot find name 'b'.
2 changes: 1 addition & 1 deletion tests/baselines/reference/parserMissingToken2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/ b;

//// [parserMissingToken2.js]
/ b;;
/ b;
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity4.ts(1,1): error TS2304: Cannot find name 'foo'.
tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity4.ts(1,5): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity4.ts(1,6): error TS1161: Unterminated regular expression literal.
tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity4.ts(1,17): error TS1005: ')' expected.
tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity4.ts(1,6): error TS2304: Cannot find name 'notregexp'.


==== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity4.ts (3 errors) ====
==== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity4.ts (4 errors) ====
foo(/notregexp);
~~~
!!! error TS2304: Cannot find name 'foo'.
~
!!! error TS1109: Expression expected.

!!! error TS1161: Unterminated regular expression literal.
!!! error TS1005: ')' expected.
~~~~~~~~~
!!! error TS2304: Cannot find name 'notregexp'.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
foo(/notregexp);

//// [parserRegularExpressionDivideAmbiguity4.js]
foo(/notregexp););
foo( / notregexp);
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//// [parserRegularExpressionDivideAmbiguity6.ts]
function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) {
let r = [];
let v;
r[0] = (v = a0*a0) & 0xFFFF;
r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF;
r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF;
r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF;
r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF;
r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF;
r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF;
r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF;
r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF;
r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF;
r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF;
r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF;
r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF;
r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF;
r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF;
r[15] = ((v / 0x10000) | 0);
return r;
}


//// [parserRegularExpressionDivideAmbiguity6.js]
function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) {
var r = [];
var v;
r[0] = (v = a0 * a0) & 0xFFFF;
r[1] = (v = ((v / 0x10000) | 0) + 2 * a0 * a1) & 0xFFFF;
r[2] = (v = ((v / 0x10000) | 0) + 2 * a0 * a2 + a1 * a1) & 0xFFFF;
r[3] = (v = ((v / 0x10000) | 0) + 2 * a0 * a3 + 2 * a1 * a2) & 0xFFFF;
r[4] = (v = ((v / 0x10000) | 0) + 2 * a0 * a4 + 2 * a1 * a3 + a2 * a2) & 0xFFFF;
r[5] = (v = ((v / 0x10000) | 0) + 2 * a0 * a5 + 2 * a1 * a4 + 2 * a2 * a3) & 0xFFFF;
r[6] = (v = ((v / 0x10000) | 0) + 2 * a0 * a6 + 2 * a1 * a5 + 2 * a2 * a4 + a3 * a3) & 0xFFFF;
r[7] = (v = ((v / 0x10000) | 0) + 2 * a0 * a7 + 2 * a1 * a6 + 2 * a2 * a5 + 2 * a3 * a4) & 0xFFFF;
r[8] = (v = ((v / 0x10000) | 0) + 2 * a1 * a7 + 2 * a2 * a6 + 2 * a3 * a5 + a4 * a4) & 0xFFFF;
r[9] = (v = ((v / 0x10000) | 0) + 2 * a2 * a7 + 2 * a3 * a6 + 2 * a4 * a5) & 0xFFFF;
r[10] = (v = ((v / 0x10000) | 0) + 2 * a3 * a7 + 2 * a4 * a6 + a5 * a5) & 0xFFFF;
r[11] = (v = ((v / 0x10000) | 0) + 2 * a4 * a7 + 2 * a5 * a6) & 0xFFFF;
r[12] = (v = ((v / 0x10000) | 0) + 2 * a5 * a7 + a6 * a6) & 0xFFFF;
r[13] = (v = ((v / 0x10000) | 0) + 2 * a6 * a7) & 0xFFFF;
r[14] = (v = ((v / 0x10000) | 0) + a7 * a7) & 0xFFFF;
r[15] = ((v / 0x10000) | 0);
return r;
}
Loading