Really strange error

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Really strange error

Jonathan Rowell


I have a strange error in eXist :

#eXist build info

(not yet switched to new release) 
with the following function in a module :-

declare function sipp:LegalDate($name,$datebit as xs:string) as xs:boolean {
if(string-length($datebit) ne 8) then
error(xs:QName('sipp:LegalDate'),concat('Field "',$name,'" not 8 characters, value is "',$value,'"'))
if(sipp:MustBeNumeric($name,$value,8)) then
true() (: for the moment :)

$value is not declared, neither locally nor globally and definitely not in any module (name is far too short!). eXide doesn't complain and neither does inspect:inspect-module, but when I test it via a test module :-

%test:args("overdue-date","20170224") %test:assertTrue
%test:args("overdue-date","2017Jan24") %test:assertError('Illegal date format')
function sipp-test:LegalDate($name as xs:string, $datebit as xs:string) as xs:boolean {

I get the following error :-

Running "exist_tester:files" (exist_tester) task
>> For sipp-test:CheckDateTime in err:XPDY0002 It is a dynamic error if evaluation of an expression relies on
some part of the dynamic context that has not been assigned a value. variable '$value' is not set.

William Candillon's xqLint does detect the error (^ [XPST0008] "value": undeclared variable) but not in the module since it is XQuery version 3.1 and uses map constructs.
Only in a test module.

BTW I must praise the test suite system - it does find errors very nicely.



Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
Exist-open mailing list
[hidden email]