Version declaration ignored if leading comment
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
Confirmed
|
Medium
|
Nicolae Brinza |
Bug Description
Create a file called "foo.query" with the following contents:
(:comment:)
jsoniq version "1.0";
let $obj := { "field1" : 42 }
return $obj.field1
(I used the extention .query to prevent zorbacmd from guessing the parser to use based on the filename extension.)
Run with "zorba /tmp/foo.query", and get:
</tmp/foo.
The spec (http://
"If [a Comment is present before the end of the version declaration], the result is implementation-
It does not say that we can ignore the version declaration itself, however.
We should throw an error about the comment before the version declaration.
Note that the version declaration IS being parsed as such in most cases. The following query runs without error:
------
(:comment:)
xquery version "1.0";
1
------
regardless of the filename extension, so it seems like the XQuery parser's grammar is capable of at least recognizing an *XQuery* version declaration after a comment. Conversely, if you create "foo.jq" (so that zorbacmd picks the JSONiq parser by default), this runs without error:
-----
(:comment:)
jsoniq version "1.0";
let $obj := { "field1" : 42 }
return $obj.field1
-----
So the JSONiq parser can parse JSONiq version declarations.
Somewhat weirdly, the following also works if the filename extension is .jq:
-----
(:comment:)
xquery version "1.0";
let $obj := { "field1" : 42 }
return $obj.field1
-----
So the version declaration is parsed *and ignored* in that case.