Treat 0x0085 as whitespace, not as a line terminator. This matches ES5 and ES6.

This commit is contained in:
Cyrus Najmabadi
2015-03-20 16:49:21 -07:00
parent 0d2a5bbf7c
commit 9ae0815e21
13 changed files with 167 additions and 87 deletions

View File

@@ -0,0 +1,9 @@
//// [fileWithNextLine1.ts]
// Note: there is a nextline (0x85) in the string
// 0. It should be counted as a space and should not cause an error.
var v = '…';
//// [fileWithNextLine1.js]
// Note: there is a nextline (0x85) in the string
// 0. It should be counted as a space and should not cause an error.
var v = '…';

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/fileWithNextLine1.ts ===
// Note: there is a nextline (0x85) in the string
// 0. It should be counted as a space and should not cause an error.
var v = '…';
>v : string

View File

@@ -0,0 +1,9 @@
//// [fileWithNextLine2.ts]
// Note: there is a nextline (0x85) char between the = and the 0.
// it should be treated like a space
var v =…0;
//// [fileWithNextLine2.js]
// Note: there is a nextline (0x85) char between the = and the 0.
// it should be treated like a space
var v = 0;

View File

@@ -0,0 +1,6 @@
=== tests/cases/compiler/fileWithNextLine2.ts ===
// Note: there is a nextline (0x85) char between the = and the 0.
// it should be treated like a space
var v =…0;
>v : number

View File

@@ -0,0 +1,9 @@
tests/cases/compiler/fileWithNextLine3.ts(3,1): error TS1108: A 'return' statement can only be used within a function body.
==== tests/cases/compiler/fileWithNextLine3.ts (1 errors) ====
// Note: there is a nextline (0x85) between the return and the
// 0. It should be counted as a space and should not trigger ASI
return…0;
~~~~~~
!!! error TS1108: A 'return' statement can only be used within a function body.

View File

@@ -0,0 +1,9 @@
//// [fileWithNextLine3.ts]
// Note: there is a nextline (0x85) between the return and the
// 0. It should be counted as a space and should not trigger ASI
return…0;
//// [fileWithNextLine3.js]
// Note: there is a nextline (0x85) between the return and the
// 0. It should be counted as a space and should not trigger ASI
return 0;

View File

@@ -1,2 +1,2 @@
//// [sourceMap-LineBreaks.js.map]
{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":"AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACzB,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACzB,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG;OACzB,CAAC"}
{"version":3,"file":"sourceMap-LineBreaks.js","sourceRoot":"","sources":["sourceMap-LineBreaks.ts"],"names":[],"mappings":"AAAA,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,0BAA0B,GAAG,EAAE,CAAC;AACpC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAAC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AACnD,IAAI,8BAA8B,GAAG,CAAC,CAAC;AACvC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,8BAA8B,GAAG,CAAC,CAAC;AAEvC,IAAI,sCAAsC,GAAG,CAAC,CAAC;AAE/C,IAAI,yBAAyB,GAAG;OACzB,CAAC;AACR,IAAI,uCAAuC,GAAG;OACvC,CAAC;AACR,IAAI,+BAA+B,GAAG;OAC/B,CAAC;AAER,IAAI,8BAA8B,GAAG;OAC9B,CAAC;AACR,IAAI,mCAAmC,GAAG;OACnC,CAAC;AACR,IAAI,yBAAyB,GAAG,gBAAgB,CAAC"}

View File

@@ -78,18 +78,18 @@ sourceFile:sourceMap-LineBreaks.ts
5 > ^
6 > ^
7 > ^^^^^^^^^^^^^^^->
1->… >
1->…
2 >var
3 > endsWithLineFeed
4 > =
5 > 1
6 > ;
1->Emitted(4, 1) Source(4, 1) + SourceIndex(0)
2 >Emitted(4, 5) Source(4, 5) + SourceIndex(0)
3 >Emitted(4, 21) Source(4, 21) + SourceIndex(0)
4 >Emitted(4, 24) Source(4, 24) + SourceIndex(0)
5 >Emitted(4, 25) Source(4, 25) + SourceIndex(0)
6 >Emitted(4, 26) Source(4, 26) + SourceIndex(0)
1->Emitted(4, 1) Source(3, 27) + SourceIndex(0)
2 >Emitted(4, 5) Source(3, 31) + SourceIndex(0)
3 >Emitted(4, 21) Source(3, 47) + SourceIndex(0)
4 >Emitted(4, 24) Source(3, 50) + SourceIndex(0)
5 >Emitted(4, 25) Source(3, 51) + SourceIndex(0)
6 >Emitted(4, 26) Source(3, 52) + SourceIndex(0)
---
>>>var endsWithCarriageReturnLineFeed = 1;
1->
@@ -105,12 +105,12 @@ sourceFile:sourceMap-LineBreaks.ts
4 > =
5 > 1
6 > ;
1->Emitted(5, 1) Source(5, 1) + SourceIndex(0)
2 >Emitted(5, 5) Source(5, 5) + SourceIndex(0)
3 >Emitted(5, 35) Source(5, 35) + SourceIndex(0)
4 >Emitted(5, 38) Source(5, 38) + SourceIndex(0)
5 >Emitted(5, 39) Source(5, 39) + SourceIndex(0)
6 >Emitted(5, 40) Source(5, 40) + SourceIndex(0)
1->Emitted(5, 1) Source(4, 1) + SourceIndex(0)
2 >Emitted(5, 5) Source(4, 5) + SourceIndex(0)
3 >Emitted(5, 35) Source(4, 35) + SourceIndex(0)
4 >Emitted(5, 38) Source(4, 38) + SourceIndex(0)
5 >Emitted(5, 39) Source(4, 39) + SourceIndex(0)
6 >Emitted(5, 40) Source(4, 40) + SourceIndex(0)
---
>>>var endsWithCarriageReturn = 1;
1 >
@@ -127,12 +127,12 @@ sourceFile:sourceMap-LineBreaks.ts
4 > =
5 > 1
6 > ;
1 >Emitted(6, 1) Source(6, 1) + SourceIndex(0)
2 >Emitted(6, 5) Source(6, 5) + SourceIndex(0)
3 >Emitted(6, 27) Source(6, 27) + SourceIndex(0)
4 >Emitted(6, 30) Source(6, 30) + SourceIndex(0)
5 >Emitted(6, 31) Source(6, 31) + SourceIndex(0)
6 >Emitted(6, 32) Source(6, 32) + SourceIndex(0)
1 >Emitted(6, 1) Source(5, 1) + SourceIndex(0)
2 >Emitted(6, 5) Source(5, 5) + SourceIndex(0)
3 >Emitted(6, 27) Source(5, 27) + SourceIndex(0)
4 >Emitted(6, 30) Source(5, 30) + SourceIndex(0)
5 >Emitted(6, 31) Source(5, 31) + SourceIndex(0)
6 >Emitted(6, 32) Source(5, 32) + SourceIndex(0)
---
>>>var endsWithLineFeedCarriageReturn = 1;
1->
@@ -148,12 +148,12 @@ sourceFile:sourceMap-LineBreaks.ts
3 > endsWithLineFeedCarriageReturn
4 > =
5 > 1
6 > ;
1->Emitted(7, 1) Source(7, 1) + SourceIndex(0)
2 >Emitted(7, 5) Source(7, 5) + SourceIndex(0)
3 >Emitted(7, 35) Source(7, 35) + SourceIndex(0)
4 >Emitted(7, 38) Source(7, 38) + SourceIndex(0)
5 >Emitted(7, 39) Source(7, 39) + SourceIndex(0)
6 > ;
1->Emitted(7, 1) Source(6, 1) + SourceIndex(0)
2 >Emitted(7, 5) Source(6, 5) + SourceIndex(0)
3 >Emitted(7, 35) Source(6, 35) + SourceIndex(0)
4 >Emitted(7, 38) Source(6, 38) + SourceIndex(0)
5 >Emitted(7, 39) Source(6, 39) + SourceIndex(0)
6 >Emitted(7, 40) Source(6, 40) + SourceIndex(0)
---
>>>var endsWithLineFeedCarriageReturnLineFeed = 1;
@@ -169,12 +169,12 @@ sourceFile:sourceMap-LineBreaks.ts
2 >var
3 > endsWithLineFeedCarriageReturnLineFeed
4 > =
5 > 1
6 > ;
1->Emitted(8, 1) Source(9, 1) + SourceIndex(0)
2 >Emitted(8, 5) Source(9, 5) + SourceIndex(0)
3 >Emitted(8, 43) Source(9, 43) + SourceIndex(0)
4 >Emitted(8, 46) Source(9, 46) + SourceIndex(0)
5 > 1
6 > ;
1->Emitted(8, 1) Source(8, 1) + SourceIndex(0)
2 >Emitted(8, 5) Source(8, 5) + SourceIndex(0)
3 >Emitted(8, 43) Source(8, 43) + SourceIndex(0)
4 >Emitted(8, 46) Source(8, 46) + SourceIndex(0)
5 >Emitted(8, 47) Source(8, 47) + SourceIndex(0)
6 >Emitted(8, 48) Source(8, 48) + SourceIndex(0)
---
@@ -187,10 +187,10 @@ sourceFile:sourceMap-LineBreaks.ts
>
>
2 >var
3 > stringLiteralWithLineFeed
4 > =
1 >Emitted(9, 1) Source(11, 1) + SourceIndex(0)
2 >Emitted(9, 5) Source(11, 5) + SourceIndex(0)
3 > stringLiteralWithLineFeed
4 > =
1 >Emitted(9, 1) Source(10, 1) + SourceIndex(0)
2 >Emitted(9, 5) Source(10, 5) + SourceIndex(0)
3 >Emitted(9, 30) Source(10, 30) + SourceIndex(0)
4 >Emitted(9, 33) Source(10, 33) + SourceIndex(0)
---
@@ -199,8 +199,8 @@ sourceFile:sourceMap-LineBreaks.ts
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >"line 1\
>line 2"
2 > ;
>line 2"
2 > ;
1 >Emitted(10, 8) Source(11, 8) + SourceIndex(0)
2 >Emitted(10, 9) Source(11, 9) + SourceIndex(0)
---
@@ -212,10 +212,10 @@ sourceFile:sourceMap-LineBreaks.ts
1->
>
2 >var
3 > stringLiteralWithCarriageReturnLineFeed
4 > =
1->Emitted(11, 1) Source(13, 1) + SourceIndex(0)
2 >Emitted(11, 5) Source(13, 5) + SourceIndex(0)
3 > stringLiteralWithCarriageReturnLineFeed
4 > =
1->Emitted(11, 1) Source(12, 1) + SourceIndex(0)
2 >Emitted(11, 5) Source(12, 5) + SourceIndex(0)
3 >Emitted(11, 44) Source(12, 44) + SourceIndex(0)
4 >Emitted(11, 47) Source(12, 47) + SourceIndex(0)
---
@@ -224,8 +224,8 @@ sourceFile:sourceMap-LineBreaks.ts
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >"line 1\
>line 2"
2 > ;
>line 2"
2 > ;
1 >Emitted(12, 8) Source(13, 8) + SourceIndex(0)
2 >Emitted(12, 9) Source(13, 9) + SourceIndex(0)
---
@@ -236,10 +236,10 @@ sourceFile:sourceMap-LineBreaks.ts
4 > ^^^
1->
>
2 >var
3 > stringLiteralWithCarriageReturn
4 > =
1->Emitted(13, 1) Source(15, 1) + SourceIndex(0)
2 >var
3 > stringLiteralWithCarriageReturn
4 > =
1->Emitted(13, 1) Source(14, 1) + SourceIndex(0)
2 >Emitted(13, 5) Source(14, 5) + SourceIndex(0)
3 >Emitted(13, 36) Source(14, 36) + SourceIndex(0)
4 >Emitted(13, 39) Source(14, 39) + SourceIndex(0)
@@ -247,8 +247,8 @@ sourceFile:sourceMap-LineBreaks.ts
>>>line 2";
1 >^^^^^^^
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >"line 1\
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >"line 1\
>line 2"
2 > ;
1 >Emitted(14, 8) Source(15, 8) + SourceIndex(0)
@@ -260,10 +260,10 @@ sourceFile:sourceMap-LineBreaks.ts
4 > ^^^
1->
>
>
2 >var
3 > stringLiteralWithLineSeparator
4 > =
>
2 >var
3 > stringLiteralWithLineSeparator
4 > =
1->Emitted(15, 1) Source(17, 1) + SourceIndex(0)
2 >Emitted(15, 5) Source(17, 5) + SourceIndex(0)
3 >Emitted(15, 35) Source(17, 35) + SourceIndex(0)
@@ -271,8 +271,8 @@ sourceFile:sourceMap-LineBreaks.ts
---
>>>line 2";
1 >^^^^^^^
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >"line 1\ >line 2"
2 > ;
1 >Emitted(16, 8) Source(18, 8) + SourceIndex(0)
@@ -282,40 +282,38 @@ sourceFile:sourceMap-LineBreaks.ts
2 >^^^^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 > ^^^
1-> >
2 >var
3 > stringLiteralWithParagraphSeparator
4 > =
1-> >
2 >var
3 > stringLiteralWithParagraphSeparator
4 > =
1->Emitted(17, 1) Source(19, 1) + SourceIndex(0)
2 >Emitted(17, 5) Source(19, 5) + SourceIndex(0)
3 >Emitted(17, 40) Source(19, 40) + SourceIndex(0)
4 >Emitted(17, 43) Source(19, 43) + SourceIndex(0)
---
---
>>>line 2";
1 >^^^^^^^
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >"line 1\ >line 2"
2 > ;
2 > ;
1 >Emitted(18, 8) Source(20, 8) + SourceIndex(0)
2 >Emitted(18, 9) Source(20, 9) + SourceIndex(0)
---
>>>var stringLiteralWithNextLine = "line 1\…line 2";
1->
2 >^^^^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^
4 > ^^^
5 > ^^^^^^^^^^^^^^^^
6 > ^
1-> >
2 >var
3 > stringLiteralWithNextLine
4 > =
1->Emitted(19, 1) Source(22, 1) + SourceIndex(0)
2 >Emitted(19, 5) Source(22, 5) + SourceIndex(0)
3 >Emitted(19, 30) Source(22, 30) + SourceIndex(0)
4 >Emitted(19, 33) Source(22, 33) + SourceIndex(0)
---
>>>line 2";
1 >^^^^^^^
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1-> >
2 >var
3 > stringLiteralWithNextLine
4 > =
5 > "line 1\…line 2"
6 > ;
1->Emitted(19, 1) Source(21, 1) + SourceIndex(0)
2 >Emitted(19, 5) Source(21, 5) + SourceIndex(0)
3 >Emitted(19, 30) Source(21, 30) + SourceIndex(0)
4 >Emitted(19, 33) Source(21, 33) + SourceIndex(0)

View File

@@ -7,24 +7,24 @@ var endsWithCarriageReturnLineFeed = 1;
var endsWithCarriageReturn = 1;
var endsWithLineFeedCarriageReturn = 1;
>endsWithNextLine : number
>endsWithNextLine : number
>endsWithLineFeed : number
var endsWithLineFeedCarriageReturnLineFeed = 1;
>endsWithCarriageReturnLineFeed : number
>endsWithCarriageReturnLineFeed : number
>endsWithCarriageReturn : number
>endsWithCarriageReturn : number
var stringLiteralWithLineFeed = "line 1\
>endsWithLineFeedCarriageReturn : number
>endsWithLineFeedCarriageReturn : number
line 2";
var stringLiteralWithCarriageReturnLineFeed = "line 1\
>endsWithLineFeedCarriageReturnLineFeed : number
line 2";
var stringLiteralWithCarriageReturn = "line 1\
line 2";
>stringLiteralWithLineFeed : string

View File

@@ -0,0 +1,3 @@
// Note: there is a nextline (0x85) in the string
// 0. It should be counted as a space and should not cause an error.
var v = '…';

View File

@@ -0,0 +1,3 @@
// Note: there is a nextline (0x85) char between the = and the 0.
// it should be treated like a space
var v =…0;

View File

@@ -0,0 +1,3 @@
// Note: there is a nextline (0x85) between the return and the
// 0. It should be counted as a space and should not trigger ASI
return…0;