From 6468fe5cf769a3787df5c31f1f12a24cf45c5508 Mon Sep 17 00:00:00 2001 From: Adam Boniecki Date: Wed, 26 Oct 2022 17:05:32 +0200 Subject: [PATCH] Cover more cases of incomplete interpolation --- src/Compiler/lex.fsl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index ada188f615d3..ab11625c7d5f 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -614,7 +614,9 @@ rule token args skip = parse // Single quote in triple quote ok, others disallowed match args.stringNest with - | _ :: _ -> errorR(Error(FSComp.SR.lexTripleQuoteInTripleQuote(), m)) + | _ :: rest -> + args.stringNest <- rest + errorR(Error(FSComp.SR.lexTripleQuoteInTripleQuote(), m)) | [] -> () if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.TripleQuote, LexerStringKind.InterpolatedStringFirst, m)) @@ -626,7 +628,9 @@ rule token args skip = parse // Single quote in triple quote ok, others disallowed match args.stringNest with | (_, LexerStringStyle.TripleQuote, _) :: _ -> () - | _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m)) + | _ :: rest -> + args.stringNest <- rest + errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m)) | _ -> () if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.SingleQuote, LexerStringKind.InterpolatedStringFirst, m)) @@ -651,7 +655,9 @@ rule token args skip = parse // Single quote in triple quote ok, others disallowed match args.stringNest with | (_, LexerStringStyle.TripleQuote, _) :: _ -> () - | _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m)) + | _ :: rest -> + args.stringNest <- rest + errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m)) | _ -> () if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.Verbatim, LexerStringKind.String, m)) @@ -663,7 +669,9 @@ rule token args skip = parse // Single quote in triple quote ok, others disallowed match args.stringNest with | (_, LexerStringStyle.TripleQuote, _) :: _ -> () - | _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m)) + | _ :: rest -> + args.stringNest <- rest + errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m)) | _ -> () if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.Verbatim, LexerStringKind.InterpolatedStringFirst, m))