-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type checking order problem [BUG] #5315
Comments
I noticed it is not related to having a function call. There is simply no top-down ordering of the type checks, as is demonstrated by the following: (: invalid variable declaration, should be caught:)
let $input as xs:string := ()
let $output as xs:string := $input
return
$output which barfs about the incorrect type of the |
@PieterLamers This is definitely a bug and not an enhancement; I have modified the labels. I can also confirm that this happens in I also note that BaseX 10.6 correctly returns the error:
|
@PieterLamers Ah, thanks for clarifying what you meant by top-down! So, as I now understand you it is the location rather than the message that is wrong. The message should definitely be improved, that is why I put the enhancement label on it. |
@line-o I don't understand what you mean by 'exist-db is not checking the type in variable declaration' as this still throws an error: let $input as xs:string := ()
return () |
I remote-debugged eXist, and ran the script
In
on the first break,
In the recursive call to
Then I moved line 110 to line 167, after the I did not make a pull request (yet) because
I thought it might be useful to share these preliminary results. When I know more, I will come back to add another comment. |
@nverwer If I remember correctly there are some issues with Lazy Evaluation of variables in eXist-db. Additionally, this should really be caught in the static analysis phase; that would be the |
@adamretter As far as I understand, the |
In addition to the above, after running eXist with the proposed change, Pieter and I have noticed several type errors in our software that were not detected without this change. Although not detecting these in |
Describe the bug
Type checking on the incorrectly typed variable is not done, or done after the variable is supplied to a function.
Expected behavior
I want the type error to be shown on the variable declaration (as does Saxon 12.3)
To Reproduce
When the following is run, it returns
exerr:ERROR XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: local:myfunction($input as xs:string) item()*. Expected cardinality: exactly one, got 0. [at line 11, column 48, source: String/-4954723990344000104] In function: local:myfunction(xs:string)
it should return
An empty sequence is not allowed as the value of variable $input
.Code to reproduce
Context (please always complete the following information)
The text was updated successfully, but these errors were encountered: