Skip to content

Commit

Permalink
Throw error if unicode is in reserved space - fixes dotnet#338
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Apr 1, 2015
1 parent 049d871 commit e68de59
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions appveyor-build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ pushd tests
call RunTests.cmd release fsharp Smoke
@if ERRORLEVEL 1 type testresults\fsharp_failures.log && echo Error: 'RunTests.cmd release fsharp Smoke' failed && goto :failure

call RunTests.cmd release fsharpqa Smoke
@if ERRORLEVEL 1 type testresults\fsharpqa_failures.log && echo Error: 'RunTests.cmd release fsharpqa Smoke' failed && goto :failure
call RunTests.cmd release fsharpqa Smoke CONFORMANCE06
@if ERRORLEVEL 1 type testresults\fsharpqa_failures.log && echo Error: 'RunTests.cmd release fsharpqa Smoke CONFORMANCE06' failed && goto :failure

call RunTests.cmd release compilerunit
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release compilerunit' failed && goto :failure
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ lexIndentOffForML,"Consider using a file with extension '.ml' or '.mli' instead"
1242,parsMissingGreaterThan,"Unmatched '<'. Expected closing '>'"
1243,parsUnexpectedQuotationOperatorInTypeAliasDidYouMeanVerbatimString,"Unexpected quotation operator '<@' in type definition. If you intend to pass a verbatim string as a static argument to a type provider, put a space between the '<' and '@' characters."
1244,parsErrorParsingAsOperatorName,"Attempted to parse this as an operator name, but failed"
1245,lexInvalidUnicodeLiteral,"This is not a valid UTF-16 literal"
# Fsc.exe resource strings
fscTooManyErrors,"Exiting - too many errors"
2001,docfileNoXmlSuffix,"The documentation file has no .xml suffix"
Expand Down
8 changes: 6 additions & 2 deletions src/fsharp/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,12 @@ and string sargs skip = parse

| unicodeGraphShort
{ let (buf,_fin,m,args) = sargs
addUnicodeChar buf (int (unicodeGraphShort (lexemeTrimLeft lexbuf 2)));
if not skip then (STRING_TEXT (LexCont.String(!args.ifdefStack,m))) else string sargs skip lexbuf }
let c = int (unicodeGraphShort (lexemeTrimLeft lexbuf 2))
if c >= 0xD800 && c <= 0xD8FF then
fail args lexbuf (FSComp.SR.lexInvalidUnicodeLiteral()) (CHAR (char c))
else
addUnicodeChar buf c;
if not skip then (STRING_TEXT (LexCont.String(!args.ifdefStack,m))) else string sargs skip lexbuf }

| unicodeGraphLong
{ let (buf,_fin,m,args) = sargs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// #Regression #Conformance #LexicalAnalysis
#light

// Verify error when trying to take the byte value of
// a unicode character literal.

//<Expects id="FS1245" span="(11,17-11,18)" status="error">This is not a valid UTF-16 literal</Expects>
//<Expects id="FS1245" span="(13,17-11,18)" status="error">This is not a valid UTF-16 literal</Expects>

let _ = '\uD7FF' // Ok

let _ = '\uD800'

let _ = "\uDFFF"

let _ = "\uE000" // Ok

exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

SOURCE=E_ByteStrUnicodeChar01.fs # E_ByteStrUnicodeChar01.fs
SOURCE=E_ByteCharUnicodeChar01.fs # E_ByteCharUnicodeChar01.fs
SOURCE=E_InvalidUnicodeChar01.fs # E_InvalidUnicodeChar01.fs

SOURCE=E_MalformedShortUnicode01.fs SCFLAGS="--test:ErrorRanges" # E_MalformedShortUnicode01.fs
SOURCE=UnicodeString03.fs # UnicodeString03.fs
Expand Down

0 comments on commit e68de59

Please sign in to comment.