Skip to content

Commit

Permalink
[haskell-servant][haskell-yesod] fix specialCharReplacements (#16289)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
msakai authored Aug 10, 2023
1 parent d955ff6 commit 9f051ec
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ public HaskellServantCodegen() {
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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ public HaskellYesodServerCodegen() {
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");
Expand Down

0 comments on commit 9f051ec

Please sign in to comment.