Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coercion rules used to convert function result to expected type #242

Closed
michaelhkay opened this issue Nov 16, 2022 · 2 comments
Closed

Coercion rules used to convert function result to expected type #242

michaelhkay opened this issue Nov 16, 2022 · 2 comments

Comments

@michaelhkay
Copy link
Contributor

michaelhkay commented Nov 16, 2022

We have separated the rules for static and dynamic function calls, which was necessary because static calls can now use keywords, whereas dynamic calls can't.

The new rules say that the coercion rules are used to convert the result to the expected result type in a dynamic call, but they fail to say that this also happens on a static call.

It would be nicer (and less error prone) if we could combine the rules. Ideally we should define that a static function call F(A, B, C) is equivalent to the dynamic call F#3(A, B, C). This in turn would be easier if we can find a way to extend function items to have optional parameters and to permit keyword arguments.

Note also that the definition of the term "coercion rules" is deficient. It doesn't say what the rules are, it just gives an example of one situation where they are used.

@michaelhkay
Copy link
Contributor Author

I'm working on the coercion rules, and notice in the XQuery version the rule:

If the function call takes place in a [module]other than the [module] (in which the function is defined, this rule must be satisfied in both the module where the function is called and the module where the function is defined (the test is repeated because the two modules may have different [in-scope schema definitions])

I think this rather bizarre rule is unnecessary because of the rules in 2.3.5:

(a) For every node that has a type annotation, if that type annotation is found in the [in-scope schema definitions] (ISSD), then its definition in the ISSD must be equivalent to its definition in the type annotation.

(b) For a given query, define a participating ISSD as the [in-scope schema definitions] of a module that is used in evaluating the query. If two participating ISSDs contain a definition for the same schema type, element name, or attribute name, the definitions must be equivalent in both ISSDs.

The effect of these rules, I believe is that the types used in different modules must be consistent to the extent that conforming to a type in one module guarantees conforming to the same type in a different module.

@michaelhkay
Copy link
Contributor Author

The issue has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant