Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[bugfix] NPE in partial application of dynamic function call #31

Merged
merged 1 commit into from

2 participants

@wolfgangmm
Owner

fixed parameters need to be analyzed when creating the partial application.

@wolfgangmm wolfgangmm [bugfix] NPE in partial application of dynamic function call: fixed p…
…arameters need to be analyzed when creating the partial application.
61b4f2a
@adamretter adamretter merged commit a758f23 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 29, 2013
  1. @wolfgangmm

    [bugfix] NPE in partial application of dynamic function call: fixed p…

    wolfgangmm authored
    …arameters need to be analyzed when creating the partial application.
This page is out of date. Refresh to see the latest.
View
1  src/org/exist/xquery/DynamicFunctionCall.java
@@ -59,6 +59,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem)
final FunctionCall call = ref.getCall();
call.setArguments(arguments);
final PartialFunctionApplication partialApp = new PartialFunctionApplication(context, call);
+ partialApp.analyze(new AnalyzeContextInfo(cachedContextInfo));
return partialApp.eval(contextSequence, contextItem);
} catch (final XPathException e) {
e.setLocation(line, column, getSource());
View
5 src/org/exist/xquery/PartialFunctionApplication.java
@@ -16,7 +16,8 @@
public final static String PARTIAL_FUN_PREFIX = "partial";
protected FunctionCall function;
-
+ protected AnalyzeContextInfo cachedContextInfo;
+
public PartialFunctionApplication(XQueryContext context, FunctionCall call) {
super(context);
this.function = call;
@@ -24,6 +25,7 @@ public PartialFunctionApplication(XQueryContext context, FunctionCall call) {
@Override
public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
+ this.cachedContextInfo = contextInfo;
}
@Override
@@ -79,6 +81,7 @@ private FunctionReference createPartial(Sequence contextSequence, Item contextIt
} else {
// fixed argument: just compute the argument value
try {
+ param.analyze(cachedContextInfo);
final Sequence seq = param.eval(contextSequence, contextItem);
callArgs.add(new PrecomputedValue(context, seq));
} catch (final XPathException e) {
View
18 test/src/xquery/xquery3/higher-order.xml
@@ -533,6 +533,24 @@ return
$ff(5, 3)]]></code>
<expected>13</expected>
</test>
+ <test output="text" id="partial4">
+ <task>Partial function application on dynamic call with function parameter</task>
+ <code><![CDATA[xquery version "3.0";
+
+declare variable $a := function($x as item()*, $f as function(item()*) as
+xs:boolean) as xs:boolean {
+ $f($x)
+};
+
+let $list := (
+ <test/>
+)
+
+let $f := $a(?, function($x){ true() })
+
+return $f($list)]]></code>
+ <expected>true</expected>
+ </test>
<test output="text" id="partiald1">
<task>Partial function application: dynamic call with partial application</task>
<code><![CDATA[xquery version "1.0";
Something went wrong with that request. Please try again.