Project

Profile

Help

Bug #1899

closed

Parameter not evaluated when the only usage is in a predicate of a pattern

Added by Michael Kay over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2013-09-12
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

A stylesheet function has a parameter $level, and the only usage of this parameter is in the predicate of a group-starting-with pattern within the function. The optimizer decides that there are no references to the parameter, therefore the parameter is not evaluated. This could cause a crash, but in this instance it leads to the pattern being evaluated as false, causing all items in the population to form a single group.

Reported (with repro) by G Imsieke on saxon-help list.

Actions #1

Updated by Michael Kay over 10 years ago

(Diagnostic notes): There seem to be two separate processes that look for all variable references. One occurs in the course of the typeCheck() phase; this is spotting the parameter reference and calling UserFunctionParameter.addReference(), which does nothing, presumably because it thinks the other process has taken care of it already. The other process (which runs first) is in XSLFunction.setParameterDefinitions(), which calls ExpressionTool.getReferenceCount() at line 475. This is returning 0 because the PatternSponsor for the group-starts-with() pattern returns 0 for getDependencies() - the dependency of the pattern on the local variable has not been recognized.

Actions #2

Updated by Michael Kay over 10 years ago

The bug is caused because the method Pattern.getDependencies() is not implemented for a PatternWithPredicate; it should return the dependencies of the predicate. The bug was introduced as a result of refactoring of the Pattern structure necessitated by generalisations of pattern syntax introduced in XSLT 3.0. A patch will be raised.

Actions #3

Updated by Michael Kay over 10 years ago

  • Status changed from In Progress to Resolved

Patch applied in Subversion on 9.5 and 9.6 branches. Test case added to W3C XSLT 3.0 test suite, test case for-each-group-071.

Actions #4

Updated by O'Neil Delpratt over 10 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.5.1.3

Big fix applied in the Saxon 9.5.1.3 maintenance release.

Please register to edit this issue

Also available in: Atom PDF