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

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

Fixed bug #991088$ (raise XUST0001 in trycatch with mixed updating and simple 
clauses)
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-991088/+merge/108535
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-05-30 00:37:00 +0000
+++ ChangeLog	2012-06-04 10:13:32 +0000
@@ -1,5 +1,9 @@
 Zorba - The XQuery Processor
 
+version 2.7
+
+  * Fixed bug #991088$ (raise XUST0001 in trycatch with mixed updating and simple clauses)
+
 version 2.5
 
 New Features:

=== modified file 'src/compiler/expression/expr.cpp'
--- src/compiler/expression/expr.cpp	2012-05-16 17:25:48 +0000
+++ src/compiler/expression/expr.cpp	2012-06-04 10:13:32 +0000
@@ -23,6 +23,7 @@
 #include <map>
 
 #include "diagnostics/assert.h"
+#include "diagnostics/util_macros.h"
 #include "diagnostics/xquery_diagnostics.h"
 
 #include "system/globalenv.h"
@@ -190,15 +191,11 @@
   {
     if (theThenExpr->is_updating() && !theElseExpr->is_updating_or_vacuous())
     {
-      throw XQUERY_EXCEPTION(err::XUST0001, 
-                             ERROR_PARAMS(ZED(XUST0001_IF)),
-                             ERROR_LOC(get_loc()));
+      RAISE_ERROR(err::XUST0001, get_loc(), ERROR_PARAMS(ZED(XUST0001_IF)));
     }
     else if (theElseExpr->is_updating() && !theThenExpr->is_updating_or_vacuous())
     {
-      throw XQUERY_EXCEPTION(err::XUST0001, 
-                             ERROR_PARAMS(ZED(XUST0001_IF)),
-                             ERROR_LOC(get_loc()));
+      RAISE_ERROR(err::XUST0001, get_loc(), ERROR_PARAMS(ZED(XUST0001_IF)));
     }
     else
     {
@@ -1294,22 +1291,47 @@
 
 void trycatch_expr::compute_scripting_kind()
 {
-  theScriptingKind = SIMPLE_EXPR;
+  bool vacuous = true;
+
+  theScriptingKind = VACUOUS_EXPR;
 
   theScriptingKind |= theTryExpr->get_scripting_detail();
 
-  ulong numCatchClauses = (ulong)theCatchClauses.size();
-
-  for (ulong i = 0; i < numCatchClauses; ++i) 
+  if (theScriptingKind != VACUOUS_EXPR)
+    vacuous = false;
+
+  csize numCatchClauses = theCatchClauses.size();
+
+  for (csize i = 0; i < numCatchClauses; ++i) 
   {
     const expr* catchExpr = theCatchExprs[i].getp();
-
     short catchKind = catchExpr->get_scripting_detail();
 
+    if (catchKind == VACUOUS_EXPR)
+      continue;
+
+    vacuous = false;
+
+    if (!theSctx->is_feature_set(feature::scripting))
+    {
+      if (is_updating() && !(catchKind & UPDATING_EXPR) && catchKind != VACUOUS_EXPR)
+      {
+        RAISE_ERROR(err::XUST0001, catchExpr->get_loc(),
+        ERROR_PARAMS(ZED(XUST0001_TRYCATCH)));
+      }
+        
+      if (!is_updating() && !is_vacuous() && (catchKind & UPDATING_EXPR))
+      {
+        RAISE_ERROR(err::XUST0001, catchExpr->get_loc(),
+        ERROR_PARAMS(ZED(XUST0001_TRYCATCH)));
+      }
+    }
+
     theScriptingKind |= catchKind;
   }
 
-  theScriptingKind &= ~VACUOUS_EXPR;
+  if (!vacuous)
+    theScriptingKind &= ~VACUOUS_EXPR;
 
   if (theScriptingKind & UPDATING_EXPR)
     theScriptingKind &= ~SIMPLE_EXPR;

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2012-05-18 22:01:56 +0000
+++ src/diagnostics/diagnostic_en.xml	2012-06-04 10:13:32 +0000
@@ -1205,6 +1205,10 @@
         <value>comma expression with updating and non-updating branches</value>
       </entry>
 
+      <entry key="TRYCATCH">
+        <value>try-catch expression with updating and non-updating clauses</value>
+      </entry>
+
       <entry key="Generic">
         <value>updating expression illegal here</value>
       </entry>

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2012-05-18 22:01:56 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2012-06-04 10:13:32 +0000
@@ -784,6 +784,7 @@
   { "~XUST0001_CONCAT", "comma expression with updating and non-updating branches" },
   { "~XUST0001_Generic", "updating expression illegal here" },
   { "~XUST0001_IF", "conditional expression with updating and non-updating branch" },
+  { "~XUST0001_TRYCATCH", "try-catch expression with updating and non-updating clauses" },
   { "~XUST0001_UDF_2", "\"$2\": function declared simple but body is updating" },
   { "~XUST0002_Transform", "transform expression witn non-updating or vacuous modify clause" },
   { "~XUST0002_UDF_2", "\"$2\": function declared updating but body is not updating or vacuous" },

=== added file 'test/rbkt/Queries/zorba/trycatch/trycatch14.spec'
--- test/rbkt/Queries/zorba/trycatch/trycatch14.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/trycatch/trycatch14.spec	2012-06-04 10:13:32 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:XUST0001

=== added file 'test/rbkt/Queries/zorba/trycatch/trycatch14.xq'
--- test/rbkt/Queries/zorba/trycatch/trycatch14.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/trycatch/trycatch14.xq	2012-06-04 10:13:32 +0000
@@ -0,0 +1,9 @@
+
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+
+declare option op:disable "scripting";
+
+
+try { 1 } catch * { delete node <a/> }
+
+

=== added file 'test/rbkt/Queries/zorba/trycatch/trycatch15.spec'
--- test/rbkt/Queries/zorba/trycatch/trycatch15.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/trycatch/trycatch15.spec	2012-06-04 10:13:32 +0000
@@ -0,0 +1,1 @@
+Error: http://www.w3.org/2005/xqt-errors:XUST0001

=== added file 'test/rbkt/Queries/zorba/trycatch/trycatch15.xq'
--- test/rbkt/Queries/zorba/trycatch/trycatch15.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/trycatch/trycatch15.xq	2012-06-04 10:13:32 +0000
@@ -0,0 +1,7 @@
+
+declare namespace op = "http://www.zorba-xquery.com/options/features";;
+
+declare option op:disable "scripting";
+
+
+try { delete node <a/> } catch * { 1 }

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to