diff --git a/appveyor-build.cmd b/appveyor-build.cmd index c6039fa11486..bd6a47095407 100644 --- a/appveyor-build.cmd +++ b/appveyor-build.cmd @@ -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 diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 2f43466da65d..d338e664abcf 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -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" diff --git a/src/fsharp/lex.fsl b/src/fsharp/lex.fsl index 2c37ee00d934..a39b130b98ca 100644 --- a/src/fsharp/lex.fsl +++ b/src/fsharp/lex.fsl @@ -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 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_InvalidUnicodeChar01.fs b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_InvalidUnicodeChar01.fs new file mode 100644 index 000000000000..850578ec8645 --- /dev/null +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/E_InvalidUnicodeChar01.fs @@ -0,0 +1,18 @@ +// #Regression #Conformance #LexicalAnalysis +#light + +// Verify error when trying to take the byte value of +// a unicode character literal. + +//This is not a valid UTF-16 literal +//This is not a valid UTF-16 literal + +let _ = '\uD7FF' // Ok + +let _ = '\uD800' + +let _ = "\uDFFF" + +let _ = "\uE000" // Ok + +exit 1 diff --git a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/env.lst b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/env.lst index 2880802f9251..92cac21288ae 100644 --- a/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/env.lst +++ b/tests/fsharpqa/Source/Conformance/LexicalAnalysis/StringsAndCharacters/env.lst @@ -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