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

Type.Is Nullable Type Rule Clarification #200

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bgribaudo
Copy link
Contributor

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.

Copy link
Contributor

@bgribaudo : Thanks for your contribution! The author(s) have been notified to review your proposed change.

Copy link
Contributor

Learn Build status updates of commit 30d1f95:

✅ Validation status: passed

File Status Preview URL Details
query-languages/m/type-is.md ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@Court72
Copy link
Contributor

Court72 commented Apr 30, 2024

@DougKlopfenstein

Can you review the proposed changes?

When the changes are ready for publication, add a #sign-off comment to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator bot added the aq-pr-triaged tracking label for the PR review team label Apr 30, 2024
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.
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@DougKlopfenstein
Copy link
Collaborator

@bgribaudo, @ehrenMSFT - has this pull request reached a conclusion? Is it ready to be merged?

@ehrenMSFT
Copy link
Contributor

@bgribaudo, @ehrenMSFT - has this pull request reached a conclusion? Is it ready to be merged?

My feedback above still applies.

@bgribaudo
Copy link
Contributor Author

@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.)

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

Successfully merging this pull request may close these issues.

4 participants