← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-899364 into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/bug-899364 into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-899364/+merge/118691

Fixed bug #899364 (throw XQST0103 in case of non-distinct window variables)
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-899364/+merge/118691
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h	2012-07-30 12:23:36 +0000
+++ include/zorba/pregenerated/diagnostic_list.h	2012-08-08 08:59:22 +0000
@@ -144,6 +144,8 @@
 
 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0099;
 
+extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0103;
+
 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0106;
 
 extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0111;

=== modified file 'modules/w3c/pregenerated/xqt-errors.xq'
--- modules/w3c/pregenerated/xqt-errors.xq	2012-07-24 08:48:48 +0000
+++ modules/w3c/pregenerated/xqt-errors.xq	2012-08-08 08:59:22 +0000
@@ -609,6 +609,14 @@
 
 (:~
  :
+ : All variables in a window clause must have distinct names.
+ : 
+ : @see http://www.w3.org/2005/xqt-errors
+:)
+declare variable $err:XQST0103 as xs:QName := fn:QName($err:NS, "err:XQST0103");
+
+(:~
+ :
  : It is a static error if a function's annotations contain more than one
  : annotation named \c private or \c public.  It is a static error if a
  : function's annotations contain more than one annotation named \c

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-07-31 22:06:33 +0000
+++ src/compiler/translator/translator.cpp	2012-08-08 08:59:22 +0000
@@ -1128,14 +1128,27 @@
 {
   assert(sctx != NULL);
 
-  if(e->get_kind() == var_expr::let_var)
+  switch (e->get_kind())
+  {
+  case var_expr::let_var:
   {
     sctx->bind_var(e, e->get_loc(), err::XQST0039);
-  }
-  else
+    break;
+  }
+  case var_expr::win_var:
+  case var_expr::wincond_out_var:
+  case var_expr::wincond_out_pos_var:
+  case var_expr::wincond_in_var:
+  case var_expr::wincond_in_pos_var:
+  {
+    sctx->bind_var(e, e->get_loc(), err::XQST0103);
+    break;
+  }
+  default:
   {
     sctx->bind_var(e, e->get_loc(), err::XQST0049);
   }
+  }
 }
 
 
@@ -5883,7 +5896,6 @@
     {
       // window var + output window condition vars
       pop_scope();
-      pop_scope();
       break;
     }
     case flwor_clause::group_clause:
@@ -6223,10 +6235,6 @@
   var_expr_t windowVarExpr = pop_nodestack_var();
   windowVarExpr->set_flwor_clause(windowClause);
 
-  // Create scope for the output window-condition vars. These vars are visible
-  // outside the window clause only.
-  push_scope();
-
   // Create var_exprs for output window-condition vars, associate them with this
   // window clause, and push them to the nodestack.
   rchandle<FLWORWinCond> cond;
@@ -6357,33 +6365,6 @@
 
 
 /*******************************************************************************
-  WindowVarDecl ::= "$" VarName TypeDeclaration? "in"  ExprSingle
-********************************************************************************/
-void* begin_visit(const WindowVarDecl& v)
-{
-  TRACE_VISIT();
-
-  // Done with input window condition vars.
-  pop_scope();
-
-  return no_state;
-}
-
-void end_visit(const WindowVarDecl& v, void* /*visit_state*/)
-{
-  TRACE_VISIT_OUT();
-
-  // Create scope for the window var
-  push_scope();
-
-  xqtref_t type = (v.get_var_type() == NULL ? NULL : pop_tstack());
-
-  var_expr_t ve = bind_var(loc, v.get_var_name(), var_expr::win_var, type);
-  push_nodestack(ve.getp());
-}
-
-
-/*******************************************************************************
   WindowStartCondition ::= "start" WindowVars "when" ExprSingle
 
   WindowEndCondition ::= "only"? "end" WindowVars "when" ExprSingle
@@ -6424,6 +6405,32 @@
 }
 
 
+/*******************************************************************************
+  WindowVarDecl ::= "$" VarName TypeDeclaration? "in"  ExprSingle
+********************************************************************************/
+void* begin_visit(const WindowVarDecl& v)
+{
+  TRACE_VISIT();
+
+  // Done with input window condition vars.
+  pop_scope();
+
+  return no_state;
+}
+
+void end_visit(const WindowVarDecl& v, void* /*visit_state*/)
+{
+  TRACE_VISIT_OUT();
+
+  // Create scope for the window var and the output window-condition vars
+  push_scope();
+
+  xqtref_t type = (v.get_var_type() == NULL ? NULL : pop_tstack());
+
+  var_expr_t ve = bind_var(loc, v.get_var_name(), var_expr::win_var, type);
+  push_nodestack(ve.getp());
+}
+
 
 /*******************************************************************************
   GroupByClause ::= "group" "by" GroupingSpecList

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2012-08-02 13:41:29 +0000
+++ src/diagnostics/diagnostic_en.xml	2012-08-08 08:59:22 +0000
@@ -605,6 +605,13 @@
       <value>module contains more than one context item declaration</value>
     </diagnostic>
 
+    <diagnostic code="XQST0103">
+      <comment>
+      All variables in a window clause must have distinct names.
+      </comment>
+      <value>$1: non-distinct variable in window clause</value>
+    </diagnostic>
+
     <diagnostic code="XQST0106">
       <comment>
        It is a static error if a function's annotations contain more than one

=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp	2012-07-30 12:23:36 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp	2012-08-08 08:59:22 +0000
@@ -199,6 +199,9 @@
 XQueryErrorCode XQST0099( "XQST0099" );
 
 
+XQueryErrorCode XQST0103( "XQST0103" );
+
+
 XQueryErrorCode XQST0106( "XQST0106" );
 
 

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2012-08-02 13:42:35 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2012-08-08 08:59:22 +0000
@@ -238,6 +238,7 @@
   { "XQST0093", "\"$1\": module must not depend on itself" },
   { "XQST0098", "properties \"$1\" and \"$2\", representing characters used in picture string, do not have distinct values" },
   { "XQST0099", "module contains more than one context item declaration" },
+  { "XQST0103", "$1: non-distinct variable in window clause" },
   { "XQST0106", "$1: multiple annotations with $2 names" },
   { "XQST0111", "$1" },
   { "XQTY0024", "element constructor content sequence must not have an attribute node following a non-attribute node" },

=== modified file 'test/rbkt/Queries/CMakeLists.txt'
--- test/rbkt/Queries/CMakeLists.txt	2012-08-03 04:35:01 +0000
+++ test/rbkt/Queries/CMakeLists.txt	2012-08-08 08:59:22 +0000
@@ -563,19 +563,8 @@
 EXPECTED_FAILURE(test/rbkt/zorba/ext_var/w3c/extvardef-016 923686)
 
 # Failing windowing tests.
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling22 899363)
-
 EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling44 899366)
 
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling14 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling16 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling15 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling18 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling19 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling20 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling17 899364)
-EXPECTED_FAILURE(test/rbkt/zorba/windowing/tumbling21 899364)
-
 # Failing due to flworfound.org hosting changes.
 EXPECTED_FAILURE(test/rbkt/zorba/versioning/import5 1022495)
 EXPECTED_FAILURE(test/rbkt/zorba/fetch/fetch_bogus2 1022494)


Follow ups