[haskell-servant][haskell-yesod] fix specialCharReplacements (#16289)

HaskellServantCodegen and HaskellYesodServerCodegen modify
specialCharReplacements by replacing its keys: backslash ("\\") with
"\\\\" and "\"" with "\\\"".

It seems that those replacements were for using the keys in string
literals in the specialChars table in the generated code. However,
modifying the keys causes the substitution of those characters in
field names not to work, making generated code syntactically invalid.

Since the specialChars table has already been removed, we can safely
stop modifying the specialCharReplacements.
This commit is contained in:
Masahiro Sakai
2023-08-10 10:43:02 +09:00
committed by GitHub
parent d955ff6988
commit 9f051ec640
2 changed files with 0 additions and 12 deletions

View File

@@ -114,12 +114,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
specialCharReplacements.put(">", "GreaterThan");
specialCharReplacements.put("<", "LessThan");
// backslash and double quote need double the escapement for both Java and Haskell
specialCharReplacements.remove("\\");
specialCharReplacements.remove("\"");
specialCharReplacements.put("\\\\", "Back_Slash");
specialCharReplacements.put("\\\"", "Double_Quote");
// set the output folder here
outputFolder = "generated-code/haskell-servant";

View File

@@ -108,12 +108,6 @@ public class HaskellYesodServerCodegen extends DefaultCodegen implements Codegen
specialCharReplacements.put(">", "GreaterThan");
specialCharReplacements.put("<", "LessThan");
// backslash and double quote need double the escapement for both Java and Haskell
specialCharReplacements.remove("\\");
specialCharReplacements.remove("\"");
specialCharReplacements.put("\\\\", "Back_Slash");
specialCharReplacements.put("\\\"", "Double_Quote");
outputFolder = "generated-code" + File.separator + "haskell-yesod";
apiTemplateFiles.put("api.mustache", ".hs");
apiTestTemplateFiles.put("api_test.mustache", ".hs");