Merge lp:~zorba-coders/zorba/bug-1029836 into lp:zorba

Proposed by Ghislain Fourny
Status: Merged
Approved by: Chris Hillery
Approved revision: 10958
Merged at revision: 10961
Proposed branch: lp:~zorba-coders/zorba/bug-1029836
Merge into: lp:zorba
Diff against target: 140 lines (+32/-2)
14 files modified
include/zorba/pregenerated/diagnostic_list.h (+2/-0)
modules/org/jsoniq/www/pregenerated/errors.xq (+5/-0)
src/compiler/translator/translator.cpp (+5/-2)
src/diagnostics/diagnostic_en.xml (+6/-0)
src/diagnostics/pregenerated/diagnostic_list.cpp (+3/-0)
src/diagnostics/pregenerated/dict_en.cpp (+3/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-1.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-1.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-2.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-2.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-3.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-3.xq (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-4.spec (+1/-0)
test/rbkt/Queries/zorba/jsoniq/jndy0018-4.xq (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1029836
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Matthias Brantner Approve
Review via email: mp+117250@code.launchpad.net

Commit message

Corrects bug 1029836.

Description of the change

Corrects bug 1029836.

To post a comment you must log in.
Revision history for this message
Ghislain Fourny (gislenius) wrote :

Hi Matthias,
I submitted a new merge proposal following Chris's request.
Regarding your question, I am not certain it is a type error. In the context of dynamic function call, it makes sense that it is a type error (XPTY0004) because it is a mismatch between the type of the function produced by the base expression and the number of provided parameters. However, in the context of object/array selection (with exactly one selector parameter), I am under the impression that this is not a type issue, but a dynamic issue (since we decided object/arrays do not match function types). What do you think?

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug-1029836 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bug-1029836-2012-07-30T12-34-05.839Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

> Hi Matthias,
> I submitted a new merge proposal following Chris's request.
> Regarding your question, I am not certain it is a type error. In the context
> of dynamic function call, it makes sense that it is a type error (XPTY0004)
> because it is a mismatch between the type of the function produced by the base
> expression and the number of provided parameters. However, in the context of
> object/array selection (with exactly one selector parameter), I am under the
> impression that this is not a type issue, but a dynamic issue (since we
> decided object/arrays do not match function types). What do you think?

I think it should be a type error for the following reason:

The JSONiq spec says

- An object matches the function type function(xs:string) as item()?.
- An array matches the function type function(xs:integer) as item()?.

The XQuery spec defines "During evaluation of an expression, it is sometimes necessary to determine whether a value with a known dynamic type "matches" an expected sequence type. This process is known as SequenceType matching." Further, the spec says "The rules for SequenceType matching compare the dynamic type of a value with an expected sequence type." All errors raised during sequence type matching are type errors.

This seems to be exactly what is being done for object and array selectors.

What do you think?

Revision history for this message
Ghislain Fourny (gislenius) wrote :

Hi Matthias,

I think you finally convinced me that it can be seen as a type error, but for a slightly different reason :-)

The spec used to say so indeed, but it is no longer the case. We decided in our e-mail discussion that objects and arrays do no match function types. Did I miss anything while updating the spec, or is any page not up-to-date?

What happens now is that the PostFixExpr grammar construct is overloaded to do either dynamic function calls (in which case arity is involved in type matching) or JSON item selection (always unary). The choice call/selection occurs dynamically based on the type of the base expression. Meaning that if the construct is not unary, it must be a call, and the type of the base expression must match function(*) - which objects and arrays do not.

I have just updated the branch accordingly. The error code now reads JNTY0018.

Thanks for your thorough feedback!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1029836-2012-07-31T09-27-02.24Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Pending.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1029836-2012-07-31T21-13-58.09Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
2--- include/zorba/pregenerated/diagnostic_list.h 2012-07-24 08:48:48 +0000
3+++ include/zorba/pregenerated/diagnostic_list.h 2012-07-31 09:19:22 +0000
4@@ -841,6 +841,8 @@
5
6 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNUP0017;
7
8+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNTY0018;
9+
10 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNTY0003;
11
12 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0040;
13
14=== modified file 'modules/org/jsoniq/www/pregenerated/errors.xq'
15--- modules/org/jsoniq/www/pregenerated/errors.xq 2012-07-11 15:38:39 +0000
16+++ modules/org/jsoniq/www/pregenerated/errors.xq 2012-07-31 09:19:22 +0000
17@@ -129,6 +129,11 @@
18 declare variable $jerr:JNUP0017 as xs:QName := fn:QName($jerr:NS, "jerr:JNUP0017");
19
20 (:~
21+ :It is a dynamic error if there is not exactly one supplied parameter for an object or array selector.
22+:)
23+declare variable $jerr:JNTY0018 as xs:QName := fn:QName($jerr:NS, "jerr:JNTY0018");
24+
25+(:~
26 :objects or arrays don't have a string value
27 :)
28 declare variable $jerr:JNTY0003 as xs:QName := fn:QName($jerr:NS, "jerr:JNTY0003");
29
30=== modified file 'src/compiler/translator/translator.cpp'
31--- src/compiler/translator/translator.cpp 2012-07-24 08:48:48 +0000
32+++ src/compiler/translator/translator.cpp 2012-07-31 09:19:22 +0000
33@@ -10645,9 +10645,12 @@
34 xqtref_t srcType = sourceExpr->get_return_type();
35
36 if (!theSctx->is_feature_set(feature::hof) ||
37- (numArgs == 1 &&
38- !TypeOps::is_subtype(tm, *srcType, *theRTM.ANY_FUNCTION_TYPE_STAR)))
39+ (!TypeOps::is_subtype(tm, *srcType, *theRTM.ANY_FUNCTION_TYPE_STAR)))
40 {
41+ if (numArgs != 1)
42+ {
43+ RAISE_ERROR_NO_PARAMS(jerr::JNTY0018, loc);
44+ }
45 function* func;
46
47 rchandle<flwor_expr> flworExpr = wrap_expr_in_flwor(sourceExpr, false);
48
49=== modified file 'src/diagnostics/diagnostic_en.xml'
50--- src/diagnostics/diagnostic_en.xml 2012-07-24 08:48:48 +0000
51+++ src/diagnostics/diagnostic_en.xml 2012-07-31 09:19:22 +0000
52@@ -2674,6 +2674,12 @@
53 <value>Cannot replace with less or more than an item.</value>
54 </diagnostic>
55
56+ <diagnostic code="JNTY0018" if="defined(ZORBA_WITH_JSON)">
57+ <comment>It is a dynamic error if there is not exactly one supplied parameter for an object or array selector.</comment>
58+
59+ <value>Object or array selection needs exactly one parameter.</value>
60+ </diagnostic>
61+
62 <!--////////// JSONIQ ///////////////////////////////////////////-->
63
64 <diagnostic code="JNTY0003" if="defined(ZORBA_WITH_JSON)">
65
66=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
67--- src/diagnostics/pregenerated/diagnostic_list.cpp 2012-07-24 08:48:48 +0000
68+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-07-31 09:19:22 +0000
69@@ -1237,6 +1237,9 @@
70 JSONiqErrorCode JNUP0017( "JNUP0017" );
71
72
73+JSONiqErrorCode JNTY0018( "JNTY0018" );
74+
75+
76 JSONiqErrorCode JNTY0003( "JNTY0003" );
77
78
79
80=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
81--- src/diagnostics/pregenerated/dict_en.cpp 2012-07-24 08:48:48 +0000
82+++ src/diagnostics/pregenerated/dict_en.cpp 2012-07-31 09:19:22 +0000
83@@ -125,6 +125,9 @@
84 { "JNTY0011", "JSON item cannot appear in content sequence of node constructor or updating expression" },
85 #endif
86 #if defined(ZORBA_WITH_JSON)
87+ { "JNTY0018", "Object or array selection needs exactly one parameter." },
88+#endif
89+#if defined(ZORBA_WITH_JSON)
90 { "JNUP0005", "\"$1\": duplicate pair to insert" },
91 #endif
92 #if defined(ZORBA_WITH_JSON)
93
94=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-1.spec'
95--- test/rbkt/Queries/zorba/jsoniq/jndy0018-1.spec 1970-01-01 00:00:00 +0000
96+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-1.spec 2012-07-31 09:19:22 +0000
97@@ -0,0 +1,1 @@
98+Error: http://www.jsoniq.org/errors:JNTY0018
99
100=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-1.xq'
101--- test/rbkt/Queries/zorba/jsoniq/jndy0018-1.xq 1970-01-01 00:00:00 +0000
102+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-1.xq 2012-07-31 09:19:22 +0000
103@@ -0,0 +1,1 @@
104+[1, 2]()
105
106=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-2.spec'
107--- test/rbkt/Queries/zorba/jsoniq/jndy0018-2.spec 1970-01-01 00:00:00 +0000
108+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-2.spec 2012-07-31 09:19:22 +0000
109@@ -0,0 +1,1 @@
110+Error: http://www.jsoniq.org/errors:JNTY0018
111
112=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-2.xq'
113--- test/rbkt/Queries/zorba/jsoniq/jndy0018-2.xq 1970-01-01 00:00:00 +0000
114+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-2.xq 2012-07-31 09:19:22 +0000
115@@ -0,0 +1,1 @@
116+[1, 2](1, 2)
117
118=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-3.spec'
119--- test/rbkt/Queries/zorba/jsoniq/jndy0018-3.spec 1970-01-01 00:00:00 +0000
120+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-3.spec 2012-07-31 09:19:22 +0000
121@@ -0,0 +1,1 @@
122+Error: http://www.jsoniq.org/errors:JNTY0018
123
124=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-3.xq'
125--- test/rbkt/Queries/zorba/jsoniq/jndy0018-3.xq 1970-01-01 00:00:00 +0000
126+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-3.xq 2012-07-31 09:19:22 +0000
127@@ -0,0 +1,1 @@
128+{ "foo" : "bar" }()
129
130=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-4.spec'
131--- test/rbkt/Queries/zorba/jsoniq/jndy0018-4.spec 1970-01-01 00:00:00 +0000
132+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-4.spec 2012-07-31 09:19:22 +0000
133@@ -0,0 +1,1 @@
134+Error: http://www.jsoniq.org/errors:JNTY0018
135
136=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-4.xq'
137--- test/rbkt/Queries/zorba/jsoniq/jndy0018-4.xq 1970-01-01 00:00:00 +0000
138+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-4.xq 2012-07-31 09:19:22 +0000
139@@ -0,0 +1,1 @@
140+{ "foo" : "bar" }(1, 2)

Subscribers

People subscribed via source and target branches