Bad GSP Code Not Flagged
Hi,
I wrote this in a GSP page:
]]>
JetGroovy didn't complain in any way about this, but when I visit that page in the Grails application, a huge pile of exception traces is shown and the browser gets a 500 response.
In fact, I could not see what was the problem, but someon on the Grails mailing list spotted it. This is the correct code:
]]>
Randall Schulz
Please sign in to leave a comment.
I'm not sure this can be reported statically.
Eugene.
Is it not a syntax error?
Certainly not: assignment is a valid groovy expression, its result is the value of the right side.
I understand that, but Maps require key/value pairs, do they not? And is this notation not that of a literal Map?
Randlal Schulz
Groovy grammar allows to mix maps and lists in one literal. Not sure about the semantics though.
I mean map and list elements of course.
What on earth is a Map that contains elements that are not key/value pairs? How do you get at those elements? And if they are allowed, then why does Grails die such a horrible death when it counters such a beast?
Randall Schulz
Don't get me wrong, but this is another matter. Formal grammar of groovy does allow this, and therefore we cannot forbid it. If we make a joint decision to ban it, ok, it will be corrected. But before that this cannot be syntax error