Skip to content

Inconsistent lazy evaluation between debug and non-debug #676

@bwrrp

Description

@bwrrp

Consider the following test case:

let $fn := function($trigger as xs:boolean, $arg as array(*)) { if ($trigger) then ($arg[1]) else () } return $fn(true(), ())

This should (and does) throw an error XPTY0004 as the $arg argument is the empty sequence, not an array. However, now consider what happens if we set $trigger to false():

let $fn := function($trigger as xs:boolean, $arg as array(*)) { if ($trigger) then ($arg[1]) else () } return $fn(false(), ())

This technically does not use the $arg argument, so I'm not sure if it's required to throw here? Unfortunately though, the behavior is different depending on the value of the debug option. Worse, it throws only if debug is off, leading to errors that typically only occur in production setups.

With debug: true: returns "" (assuming evaluation to STRING)

With debug: false: throws Uncaught Error: XPTY0004: Multiplicity of function argument of type array(*) for dynamic-function is incorrect. Expected exactly one

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions