Project

Profile

Help

Bug #4772

closed

Diagnostics for type errors on $map(xx) and $array(xx)

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

Status:
Closed
Priority:
Low
Assignee:
Category:
Diagnostics
Sprint/Milestone:
-
Start date:
2020-10-02
Due date:
% Done:

100%

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

Description

A dynamic function call on a map ($map(xx)) is converted at compile time to a static function call (map:get($map, xx)).

This leads to poor diagnostics if there is a type error in xx: for example

An empty sequence is not allowed as the second argument of map:get()

The same problem applies to calls on $array(index)

Actions #1

Updated by Michael Kay over 3 years ago

The problem can be demonstrated from the command line:

-qs:"declare variable $p external;map{'a':1}($p)" -t ?p=()

The problem can be fixed at the point where we create the call on map:get(). In ApplyFn.makeGetCall(), after

Expression getter = fnSet.makeFunction("get", 2).makeFunctionCall(target, key);

and before the call on getter.staticTypeCheck(), we can do custom type-checking on the second argument with a custom RoleDiagnostic. After this change the error becomes

An empty sequence is not allowed as the key value supplied when calling a map as a function

And similarly, mutatis mutandis, for a call on $array(xx)

Actions #2

Updated by Michael Kay over 3 years ago

  • Status changed from New to Resolved
  • Fix Committed on Branch 10, trunk added
Actions #3

Updated by O'Neil Delpratt over 3 years ago

Bug fix applied in the Saxon 10.3 maintenance release

Actions #4

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.3 added

Please register to edit this issue

Also available in: Atom PDF