-
Notifications
You must be signed in to change notification settings - Fork 75
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
Type.Is Nullable Type Rule Clarification #200
base: main
Are you sure you want to change the base?
Conversation
@bgribaudo : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
Learn Build status updates of commit 30d1f95: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Can you review the proposed changes? When the changes are ready for publication, add a #label:"aq-pr-triaged" |
Determines if a value of `type1` is always compatible with `type2`. | ||
Determines if a value of `type1` is always compatible with `type2`. | ||
|
||
Parameter `type2` is expected to be a nullable primitive type. When this requirement is not met, this function's behavior is undefined and so should not be relied on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true. By passing a nullable primitive type as the second arg, you can use Type.Is to check for both the nullable and non-nullable version of that type. But that's just one use of the function.
Here's another way it can be used, which doesn't involve nullable types at all:
Type.Is(Int64.Type, type number)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ehrenMSFT,
Thanks for this feedback.
Here's another way it can be used, which doesn't involve nullable types at all:
Type.Is(Int64.Type, type number)
I'm puzzled. Isn't type number
a nullable primitive type (where nullable primitive type = all primitive types + their nullable counterparts)?
In the language spec, operators as
and is
are described as only accepting "nullable primitive types as their right operand," and Value.Is
's second argument is described as accepting "an arbitrary type value as its first and a nullable primitive type value as its second argument." Examples are given like Type.Is(type number, type text)
and 1 is number
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the spec. I'm just basing my comments on how things actually seem to work.
Type.IsNullable(type number) returns false. You'd have to say "type nullable number" to make it nullable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ehrenMSFT!
Just opened a PR raising the question of how to best address the "nullable primitive type" terminology used in the spec.
@bgribaudo, @ehrenMSFT - has this pull request reached a conclusion? Is it ready to be merged? |
My feedback above still applies. |
@DougKlopfenstein, thanks for checking up on this. This is blocked by #203. (That PR renames a term in the language spec which can then be used here to resolve @ehrenMSFT's feedback.) |
Per https://learn.microsoft.com/en-us/powerquery-m/m-spec-types#type-equivalence-and-compatibility, this function's second parameter should only ever be a nullable primitive type.
This PR adds details about this requirement to the function's docs.