Skip to content

Commit

Permalink
Fixed modules not being a restricted keyword. Fixes #993
Browse files Browse the repository at this point in the history
The name is now also checked against the keyword list in singularized form.
Also fixed an undefined error in the js error hint
  • Loading branch information
mpscholten committed Jul 23, 2021
1 parent 87ecfc9 commit 84d9895
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion IHP/IDE/SchemaDesigner/Controller/Validation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ isIllegalKeyword :: Text -> Bool
isIllegalKeyword input =
case input of
"_" -> True
_ -> isSQLKeyword input || isHaskellKeyword input
_ -> isSQLKeyword input || (isHaskellKeyword (singularize input))

isSQLKeyword :: Text -> Bool
isSQLKeyword input = case (toUpper input) of
Expand Down
4 changes: 2 additions & 2 deletions lib/IHP/static/IDE/ihp-schemadesigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ function initSchemaDesigner() {
var reservedKeywords = [ "_", "as", "case", "class", "data", "default", "deriving", "do", "else", "hiding", "if"
, "import", "in", "infix", "infixl", "infixr", "instance", "let", "module", "newtype", "of", "qualified", "then"
, "type", "where", "forall", "mdo", "family", "role", "pattern", "static", "group", "by", "using", "foreign", "export"
, "label", "dynamic", "safe", "interruptible", "unsafe", "stdcall", "ccall", "capi", "prim", "javascript", "rec", "proc" ]
, "label", "dynamic", "safe", "interruptible", "unsafe", "stdcall", "ccall", "capi", "prim", "javascript", "rec", "proc" ];
if (reservedKeywords.includes(this.value)) {
this.classList = "form-control is-invalid"
var warning = document.createElement("div");
warning.innerHTML =
"'" + this.value + "' is a reserved keyword in Haskell. "
+ "Consider renaming it to '"
+ this.dataset.tableNameSingular + "_" + this.value
+ (this.dataset.tableNameSingular || 'something') + "_" + this.value
+ "'.";
warning.classList = "invalid-feedback";
warning.setAttribute("id", "warningText");
Expand Down

0 comments on commit 84d9895

Please sign in to comment.