Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/bug-1123165 into lp:zorba.
Requested reviews: Matthias Brantner (matthias-brantner) Related bugs: Bug #1123165 in Zorba: "failures in require-feature and prohibit-feature (at least 27)" https://bugs.launchpad.net/zorba/+bug/1123165 For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug-1123165/+merge/159822 Fixing bug 1123165 (prohibit/require feature tests). -- https://code.launchpad.net/~zorba-coders/zorba/bug-1123165/+merge/159822 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/pregenerated/diagnostic_list.h' --- include/zorba/pregenerated/diagnostic_list.h 2013-04-04 04:14:46 +0000 +++ include/zorba/pregenerated/diagnostic_list.h 2013-04-19 13:05:34 +0000 @@ -162,8 +162,14 @@ extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0114; +extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0120; + extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0123; +extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0126; + +extern ZORBA_DLL_PUBLIC XQueryErrorCode XQST0128; + extern ZORBA_DLL_PUBLIC XQueryErrorCode XPDY0002; extern ZORBA_DLL_PUBLIC XQueryErrorCode XPDY0050; === modified file 'modules/w3c/pregenerated/xqt-errors.xq' --- modules/w3c/pregenerated/xqt-errors.xq 2013-04-04 04:14:46 +0000 +++ modules/w3c/pregenerated/xqt-errors.xq 2013-04-19 13:05:34 +0000 @@ -692,6 +692,15 @@ (:~ : + : It is a static error if a feature required by require-feature is not + : supported by the implementation. + : + : @see http://www.w3.org/2005/xqt-errors +:) +declare variable $err:XQST0120 as xs:QName := fn:QName($err:NS, "err:XQST0120"); + +(:~ + : : It is a static error if the name of a feature in require-feature is not : recognized by the implementation. : @@ -701,6 +710,24 @@ (:~ : + : It is a static error if all-extensions appears in a require-feature option declaration. + : + : @see http://www.w3.org/2005/xqt-errors +:) +declare variable $err:XQST0126 as xs:QName := fn:QName($err:NS, "err:XQST0126"); + +(:~ + : + : It is a static error if a feature name that an implementation supports appears + : in a prohibit-feature option declaration, and the implementation is unable to + : disable the feature. + : + : @see http://www.w3.org/2005/xqt-errors +:) +declare variable $err:XQST0128 as xs:QName := fn:QName($err:NS, "err:XQST0128"); + +(:~ + : : 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. : === modified file 'src/compiler/parser/scanner.l' --- src/compiler/parser/scanner.l 2013-04-17 22:41:05 +0000 +++ src/compiler/parser/scanner.l 2013-04-19 13:05:34 +0000 @@ -147,8 +147,8 @@ | | String literal definitions |______________________________________________________________________*/ -NonQuotAnd [^""&] -NonAposAnd [^''&] +NonQuotAnd [^\"&] +NonAposAnd [^\'&] #ifdef XQUERY_SCANNER StringLiteral ({Quote}({EscapeQuot}|{Ref}|{NonQuotAnd})*{Quote})|({Apos}({EscapeApos}|{Ref}|{NonAposAnd})*{Apos}) #else === modified file 'src/compiler/translator/translator.cpp' --- src/compiler/translator/translator.cpp 2013-04-18 08:47:43 +0000 +++ src/compiler/translator/translator.cpp 2013-04-19 13:05:34 +0000 @@ -3856,6 +3856,8 @@ bind_fn(f, numParams, loc); } + theSctx->check_xquery_feature_options(loc); + return no_state; } @@ -11718,7 +11720,21 @@ TypeManager* tm = sourceExpr->get_type_manager(); xqtref_t srcType = sourceExpr->get_return_type(); - if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_ITEM_TYPE_STAR)) + if (TypeOps::is_subtype(tm, *srcType, *theRTM.EMPTY_TYPE) && + numArgs > 1) + { + // If the source expression is the empty sequence and there is more than + // one parameter, we should still consider it a dynamic invocation. + fc->set_allowing_empty(true); + + expr* dynFuncInvocation = + CREATE(dynamic_function_invocation)(theRootSctx, theUDF, loc, + flworVarExpr, + arguments); + + flworExpr->set_return_expr(dynFuncInvocation); + } + else if (TypeOps::is_subtype(tm, *srcType, *theRTM.JSON_ITEM_TYPE_STAR)) { if (numArgs > 1) { === modified file 'src/context/static_context.cpp' --- src/context/static_context.cpp 2013-04-16 07:43:15 +0000 +++ src/context/static_context.cpp 2013-04-19 13:05:34 +0000 @@ -3505,6 +3505,217 @@ // // ///////////////////////////////////////////////////////////////////////////////// +/***************************************************************************//** + +********************************************************************************/ +void static_context::check_xquery_feature_options(const QueryLoc& loc) +{ + if (theOptionMap == NULL) + { + return; + } + // Looking up feature options. + zstring lRequiredFeatureList; + zstring lProhibitedFeatureList; + + store::Item_t lRequireFeatureQName = + parse_and_expand_qname("require-feature", XQUERY_NS, loc); + store::Item_t lProhibitFeatureQName = + parse_and_expand_qname("prohibit-feature", XQUERY_NS, loc); + OptionMap::iterator lIt = theOptionMap->find(lRequireFeatureQName.getp()); + if (lIt != theOptionMap->end()) + { + lRequiredFeatureList = lIt.getValue().theValue; + } + lIt = theOptionMap->find(lProhibitFeatureQName.getp()); + if (lIt != theOptionMap->end()) + { + lProhibitedFeatureList = lIt.getValue().theValue; + } + + // Constructing feature vectors. + vector<zstring> lRequiredFeatures; + size_t lPositionLeft = 0; + size_t lPositionRight = lRequiredFeatureList.find(" ", lPositionLeft); + while (lPositionRight != zstring::npos) + { + zstring lFeature = lRequiredFeatureList.substr( + lPositionLeft, + lPositionRight - lPositionLeft); + store::Item_t lFeatureQName = parse_and_expand_qname( + lFeature, + XQUERY_NS, + loc); + if (lFeatureQName->getNamespace() != XQUERY_NS) + { + RAISE_ERROR(err::XQST0123, loc, ERROR_PARAMS(lFeature)); + } + lRequiredFeatures.push_back(lFeatureQName->getLocalName()); + lPositionLeft = lPositionRight + 1; + lPositionRight = lRequiredFeatureList.find(" ", lPositionLeft); + } + if (!lRequiredFeatureList.empty()) + { + zstring lFeature = lRequiredFeatureList.substr(lPositionLeft); + store::Item_t lFeatureQName = parse_and_expand_qname( + lFeature, + XQUERY_NS, + loc); + if (lFeatureQName->getNamespace() != XQUERY_NS) + { + RAISE_ERROR(err::XQST0123, loc, ERROR_PARAMS(lFeature)); + } + lRequiredFeatures.push_back(lFeatureQName->getLocalName()); + } + + vector<zstring> lProhibitedFeatures; + lPositionLeft = 0; + lPositionRight = lProhibitedFeatureList.find(" ", lPositionLeft); + while (lPositionRight != zstring::npos) + { + zstring lFeature = lProhibitedFeatureList.substr( + lPositionLeft, + lPositionRight - lPositionLeft); + store::Item_t lFeatureQName = parse_and_expand_qname( + lFeature, + XQUERY_NS, + loc); + if (lFeatureQName->getNamespace() == XQUERY_NS) + { + lProhibitedFeatures.push_back(lFeatureQName->getLocalName()); + } + lPositionLeft = lPositionRight + 1; + lPositionRight = lProhibitedFeatureList.find(" ", lPositionLeft); + } + if (!lProhibitedFeatureList.empty()) + { + zstring lFeature = lProhibitedFeatureList.substr(lPositionLeft); + store::Item_t lFeatureQName = parse_and_expand_qname( + lFeature, + XQUERY_NS, + loc); + if (lFeatureQName->getNamespace() == XQUERY_NS) + { + lProhibitedFeatures.push_back(lFeatureQName->getLocalName()); + } + } + + // Going through feature flags. + bool lStaticTypingRequired = false; + bool lModuleRequired = false; + bool lHOFRequired = false; + bool lSchemaAwareRequired = false; + bool lAllExtensionsRequired = false; + bool lAllOptionalFeaturesRequired = false; + for (vector<zstring>::iterator it = lRequiredFeatures.begin(); + it != lRequiredFeatures.end(); + ++it) + { + std::cout << "lRequiredFeature: " << *it << std::endl; + if (*it == "static-typing") + { + lStaticTypingRequired = true; + } else if (*it == "module") + { + lModuleRequired = true; + } else if (*it == "higher-order-function") + { + lHOFRequired = true; + } else if (*it == "schema-aware") + { + lSchemaAwareRequired = true; + } else if (*it == "all-extensions") + { + lAllExtensionsRequired = true; + } else if (*it == "all-optional-features") + { + lAllOptionalFeaturesRequired = true; + } else + { + RAISE_ERROR(err::XQST0123, loc, ERROR_PARAMS(*it)); + } + } + + bool lStaticTypingProhibited = false; + bool lModuleProhibited = false; + bool lHOFProhibited = false; + bool lSchemaAwareProhibited = false; + bool lAllExtensionsProhibited = false; + bool lAllOptionalFeaturesProhibited = false; + for (vector<zstring>::iterator it = lProhibitedFeatures.begin(); + it != lProhibitedFeatures.end(); + ++it) + { + std::cout << "lProhibitedFeature: " << *it << std::endl; + if (*it == "static-typing") + { + lStaticTypingProhibited = true; + } else if (*it == "module") + { + lModuleProhibited = true; + } else if (*it == "higher-order-function") + { + lHOFProhibited = true; + } else if (*it == "schema-aware") + { + lSchemaAwareProhibited = true; + } else if (*it == "all-extensions") + { + lAllExtensionsProhibited = true; + } else if (*it == "all-optional-features") + { + lAllOptionalFeaturesProhibited = true; + } + } + // static-typing is not supported. + if (lStaticTypingRequired) + { + RAISE_ERROR(err::XQST0120, loc, ERROR_PARAMS("static-typing")); + } + // It is not possible to require all extensions. + if (lAllExtensionsRequired) + { + RAISE_ERROR(err::XQST0120, loc, ERROR_PARAMS("all-extensions")); + } + // All optional features can only be required if static-typing is prohibited. + if (lAllOptionalFeaturesRequired) + { + if (!lStaticTypingProhibited) + { + RAISE_ERROR(err::XQST0120, loc, ERROR_PARAMS("static-typing")); + } + } + // Supported features cannot be prohibited. + if (lSchemaAwareProhibited) + { + RAISE_ERROR(err::XQST0128, loc, ERROR_PARAMS("schema-aware")); + } + if (lHOFProhibited) + { + RAISE_ERROR(err::XQST0128, loc, ERROR_PARAMS("higher-order-function")); + } + if (lModuleProhibited) + { + RAISE_ERROR(err::XQST0128, loc, ERROR_PARAMS("module")); + } + // All optional features can only be prohibited if all three that are supported + // are required. + if (lAllOptionalFeaturesProhibited) + { + if (!lModuleRequired) + { + RAISE_ERROR(err::XQST0128, loc, ERROR_PARAMS("module")); + } + if (!lHOFRequired) + { + RAISE_ERROR(err::XQST0128, loc, ERROR_PARAMS("higher-order-function")); + } + if (!lSchemaAwareRequired) + { + RAISE_ERROR(err::XQST0128, loc, ERROR_PARAMS("schema-aware")); + } + } +} /***************************************************************************//** @@ -3524,12 +3735,23 @@ store::Item* qname2 = option.theName.getp(); zstring lNamespace = qname2->getNamespace(); + zstring lLocalName = qname2->getLocalName(); + // If option namespace is the XQuery namespace. + if ( lNamespace == XQUERY_NS) + { + OptionMap::iterator lIt = theOptionMap->find(qname2); + if (lIt != theOptionMap->end()) + { + std::ostringstream lOss; + lOss << lIt.getValue().theValue << " " << option.theValue; + option.theValue = lOss.str(); + } + } + // If option namespace starts with zorba options namespace if ( lNamespace.find(ZORBA_OPTIONS_NS) == 0 ) { - zstring lLocalName = qname2->getLocalName(); - if (lNamespace == ZORBA_OPTION_FEATURE_NS && (lLocalName == "enable" || lLocalName == "disable")) { === modified file 'src/context/static_context.h' --- src/context/static_context.h 2013-04-02 21:43:27 +0000 +++ src/context/static_context.h 2013-04-19 13:05:34 +0000 @@ -1011,6 +1011,8 @@ const zstring& option, const QueryLoc& loc); + void check_xquery_feature_options(const QueryLoc& loc); + bool lookup_option(const store::Item* qname, zstring& option) const; bool is_feature_set(feature::kind k) const { return (theFeatures & k) != 0; } @@ -1036,7 +1038,7 @@ const zstring& value, const char* default_ns, const QueryLoc& loc) const; - + void set_feature(feature::kind k) { theFeatures |= k; } void unset_feature(feature::kind k) { theFeatures &= ~k; } === modified file 'src/diagnostics/diagnostic_en.xml' --- src/diagnostics/diagnostic_en.xml 2013-04-10 02:24:08 +0000 +++ src/diagnostics/diagnostic_en.xml 2013-04-19 13:05:34 +0000 @@ -830,15 +830,39 @@ </comment> <value>"$1": duplicate decimal format property</value> </diagnostic> - + + <diagnostic code="XQST0120"> + <comment> + It is a static error if a feature required by require-feature is not + supported by the implementation. + </comment> + <value>Feature "$1" is not supported by Zorba.</value> + </diagnostic> + <diagnostic code="XQST0123"> <comment> - It is a static error if the name of a feature in require-feature is not - recognized by the implementation. + It is a static error if the name of a feature in require-feature is not + recognized by the implementation. </comment> <value>$1</value> </diagnostic> - + + <diagnostic code="XQST0126"> + <comment> + It is a static error if all-extensions appears in a require-feature option declaration. + </comment> + <value>It is impossible to activate all extension features.</value> + </diagnostic> + + <diagnostic code="XQST0128"> + <comment> + It is a static error if a feature name that an implementation supports appears + in a prohibit-feature option declaration, and the implementation is unable to + disable the feature. + </comment> + <value>Feature "$1" is supported by Zorba, and Zorba is unable to disable it.</value> + </diagnostic> + <diagnostic code="XPDY0002"> <comment> It is a dynamic error if evaluation of an expression relies on some part === modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp' --- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-04-04 04:14:46 +0000 +++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-04-19 13:05:34 +0000 @@ -226,9 +226,18 @@ XQueryErrorCode XQST0114( "XQST0114" ); +XQueryErrorCode XQST0120( "XQST0120" ); + + XQueryErrorCode XQST0123( "XQST0123" ); +XQueryErrorCode XQST0126( "XQST0126" ); + + +XQueryErrorCode XQST0128( "XQST0128" ); + + XQueryErrorCode XPDY0002( "XPDY0002" ); === modified file 'src/diagnostics/pregenerated/dict_en.cpp' --- src/diagnostics/pregenerated/dict_en.cpp 2013-04-10 02:24:08 +0000 +++ src/diagnostics/pregenerated/dict_en.cpp 2013-04-19 13:05:34 +0000 @@ -262,7 +262,10 @@ { "XQST0106", "$1: multiple annotations with $2 names" }, { "XQST0111", "$1" }, { "XQST0114", "\"$1\": duplicate decimal format property" }, + { "XQST0120", "Feature \"$1\" is not supported by Zorba." }, { "XQST0123", "$1" }, + { "XQST0126", "It is impossible to activate all extension features." }, + { "XQST0128", "Feature \"$1\" is supported by Zorba, and Zorba is unable to disable it." }, { "XQTY0024", "element constructor content sequence must not have an attribute node following a non-attribute node" }, { "XQTY0030", "validate argument must be exactly one document or element node" }, { "XQTY0086", "typed value of copied element or attribute node is namespace-sensitive when construction mode is preserve and copy-namespaces mode is no-preserve" }, === modified file 'test/fots/CMakeLists.txt' --- test/fots/CMakeLists.txt 2013-04-19 00:21:18 +0000 +++ test/fots/CMakeLists.txt 2013-04-19 13:05:34 +0000 @@ -380,29 +380,6 @@ EXPECTED_FOTS_FAILURE (prod-OrderByClause orderBy50 0) EXPECTED_FOTS_FAILURE (prod-OrderByClause orderBy51 0) EXPECTED_FOTS_FAILURE (prod-OrderByClause orderBy59 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-static-typing-1-ns 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-higher-order-function-9-ns 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-schema-aware-1-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-schema-aware-2-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-1-ns 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-2-ns 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-3-ns 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-4-ns 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature unknown-feature 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature well-formed-feature-1 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature well-formed-feature-2 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature well-formed-feature-3 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature well-formed-feature-4 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-prohibit-1 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-prohibit-2 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-prohibit-3 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-prohibit-4 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-prohibit-5 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-all-extensions-1 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-all-optional-features-3-ns3 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-all-optional-features-2-ns2 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-all-optional-features-1 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-all-optional-features-7-s 0) EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema031 0) EXPECTED_FOTS_FAILURE (prod-SchemaImport substitution-001 0) EXPECTED_FOTS_FAILURE (prod-SchemaImport substitution-002 0) @@ -463,15 +440,6 @@ EXPECTED_FOTS_FAILURE (misc-HigherOrderFunctions xqhof12 0) EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-062 0) EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-494 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-higher-order-function-5-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature require-higher-order-function-10-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-1-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-2-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-3-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature prohibit-higher-order-function-4-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature separate-modules-5-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature separate-modules-6-s 0) -EXPECTED_FOTS_FAILURE (prod-RequireProhibitFeature separate-modules-7-s 0) EXPECTED_FOTS_FAILURE (prod-SchemaImport substitution-030 0) EXPECTED_FOTS_FAILURE (prod-SchemaImport substitution-031 0) EXPECTED_FOTS_FAILURE (prod-SchemaImport substitution-032 0)
-- 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