From: simonmar Date: Fri, 13 Dec 2002 16:04:56 +0000 (+0000) Subject: [project @ 2002-12-13 16:04:56 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~1346 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a634e56332b8bac41400b9b344b4fb13dd57fb88;p=ghc-hetmet.git [project @ 2002-12-13 16:04:56 by simonmar] When lexing a primitive string, always make a "narrow" FastString. Otherwise when the string contains zeros we get a Unicode string, which luckily turns into the right thing when compiled but confuses the byte-code generator. So this fixes the symptom (byte-code generator can't load files generated with happy -ag), but not the real bug (byte-code generator can't handle unicode strings). --- diff --git a/ghc/compiler/parser/Lex.lhs b/ghc/compiler/parser/Lex.lhs index 135b207..9ae21ef 100644 --- a/ghc/compiler/parser/Lex.lhs +++ b/ghc/compiler/parser/Lex.lhs @@ -665,12 +665,16 @@ lex_string cont exts s buf = case currentChar# buf of '"'#{-"-} -> let buf' = incCurrentPos buf - s' = mkFastString (map chr (reverse s)) in case currentChar# buf' of - '#'# | glaExtsEnabled exts -> if all (<= 0xFF) s - then cont (ITprimstring s') (incCurrentPos buf') - else lexError "primitive string literal must contain only characters <= \'\\xFF\'" buf' - _ -> cont (ITstring s') buf' + '#'# | glaExtsEnabled exts -> + if any (> 0xFF) s + then lexError "primitive string literal must contain only characters <= \'\\xFF\'" buf' + else let s' = mkFastStringNarrow (map chr (reverse s)) in + -- always a narrow string/byte array + cont (ITprimstring s') (incCurrentPos buf') + + _other -> let s' = mkFastString (map chr (reverse s)) + in cont (ITstring s') buf' -- ignore \& in a string, deal with string gaps '\\'# | next_ch `eqChar#` '&'#