Skip to content
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

[BUG] implicit cast to xs:string (exist-db 6.x.x) #5303

Open
line-o opened this issue May 13, 2024 · 1 comment
Open

[BUG] implicit cast to xs:string (exist-db 6.x.x) #5303

line-o opened this issue May 13, 2024 · 1 comment
Labels
bug issue confirmed as bug xquery issue is related to xquery implementation
Milestone

Comments

@line-o
Copy link
Member

line-o commented May 13, 2024

Describe the bug

Some variable types might be implicitly cast to strings.

Expected behavior

The XQuery runtime to not implicitly cast to strings where the language specification does not allow it but to raise an error instead.

To Reproduce

xquery version "3.1";

module namespace typetest="http://exist-db.org/xquery/types/test";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $typetest:implicit-binary := xs:base64Binary("text");
declare variable $typetest:explicit-binary as xs:base64Binary := xs:base64Binary("text");

declare
    %test:assertError("err:XPTY0004")
function typetest:direct-input() {
    xmldb:encode(xs:base64Binary("text"))
};

declare
    %test:assertError("err:XPTY0004")
function typetest:implicitly-typed-module-variable() {
    xmldb:encode($typetest:implicit-binary)
};

declare
    %test:assertError("err:XPTY0004")
function typetest:explicitly-typed-module-variable() {
    xmldb:encode($typetest:explicit-binary)
};

declare
    %test:assertError("err:XPTY0004")
function typetest:implicitly-typed-local-variable() {
    let $implicit := xs:base64Binary("text")
    return xmldb:encode($implicit)
};

declare
    %test:assertError("err:XPTY0004")
function typetest:explicitly-typed-local-variable() {
    let $explicit as xs:base64Binary := xs:base64Binary("text")
    return xmldb:encode($explicit)
};

declare
    %test:assertError("err:XPTY0004")
function typetest:implicitly-typed-variable-arrow() {
    let $implicit := xs:base64Binary("text")
    return $implicit => xmldb:encode()
};

declare
    %test:assertError("err:XPTY0004")
function typetest:explicitly-typed-variable-arrow() {
    let $explicit as xs:base64Binary := xs:base64Binary("text")
    return $explicit => xmldb:encode()
};

Running the above on exist-db 6.2.0 you'll get (I did not try develop nor develop-6)

<testsuites>
    <testsuite package="http://exist-db.org/xquery/types/test" timestamp="2024-05-13T14:22:11.717+02:00" tests="7" failures="3" errors="0" pending="0" time="PT0.013S">
        <testcase name="direct-input" class="typetest:direct-input"/>
        <testcase name="explicitly-typed-local-variable" class="typetest:explicitly-typed-local-variable"/>
        <testcase name="explicitly-typed-module-variable" class="typetest:explicitly-typed-module-variable"/>
        <testcase name="explicitly-typed-variable-arrow" class="typetest:explicitly-typed-variable-arrow">
            <failure message="Expected error err:XPTY0004." type="failure-error-code-1"/>
            <output>text</output>
        </testcase>
        <testcase name="implicitly-typed-local-variable" class="typetest:implicitly-typed-local-variable">
            <failure message="Expected error err:XPTY0004." type="failure-error-code-1"/>
            <output>text</output>
        </testcase>
        <testcase name="implicitly-typed-module-variable" class="typetest:implicitly-typed-module-variable"/>
        <testcase name="implicitly-typed-variable-arrow" class="typetest:implicitly-typed-variable-arrow">
            <failure message="Expected error err:XPTY0004." type="failure-error-code-1"/>
            <output>text</output>
        </testcase>
    </testsuite>
</testsuites>

Context (please always complete the following information)

Build: eXist-6.2.0 (4d2b1bcdf15cccbc60aa7fd02ade2722a800161d)
Java: 1.8.0_402 (Azul Systems, Inc.)
OS: Mac OS X 14.4.1 (aarch64)

Additional context

  • How is eXist-db installed? built from source
  • Any custom changes in e.g. conf.xml? none
@line-o line-o changed the title [BUG] [BUG] implicit cast to xs:string May 13, 2024
@line-o line-o added bug issue confirmed as bug xquery issue is related to xquery implementation labels May 16, 2024
@line-o
Copy link
Member Author

line-o commented May 16, 2024

I just tested this with latest develop (7.0.0-SNAPSHOT).
It is fixed there.

@line-o line-o changed the title [BUG] implicit cast to xs:string [BUG] implicit cast to xs:string (exist-db 6.x.x) May 16, 2024
@joewiz joewiz added this to the eXist-6.2.1 milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue confirmed as bug xquery issue is related to xquery implementation
Projects
None yet
Development

No branches or pull requests

2 participants