Skip to content

[compiler] Preserve TSNonNullExpressions #33097

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

Open
wants to merge 1 commit into
base: gh/josephsavona/78/base
Choose a base branch
from

Conversation

josephsavona
Copy link
Contributor

@josephsavona josephsavona commented May 2, 2025

Stack from ghstack (oldest at bottom):

This is a first step toward teaching the compiler that TS non-null expressions mean a variable may be nullable and that we can't take dependencies past the non-null assertion - see #33054.

To start, we add a new instruction type and add support from lowering through codegen.

This is a first step toward teaching the compiler that TS non-null expressions mean a variable may be nullable and that we can't take dependencies past the non-null assertion.

To start, we add a new instruction type and add support from lowering through codegen.

[ghstack-poisoned]
josephsavona added a commit that referenced this pull request May 2, 2025
This is a first step toward teaching the compiler that TS non-null expressions mean a variable may be nullable and that we can't take dependencies past the non-null assertion.

To start, we add a new instruction type and add support from lowering through codegen.

ghstack-source-id: 730319c60e173f347705e8d29f12deca44bfaf88
Pull Request resolved: #33097
Copy link
Contributor

@mvitousek mvitousek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be relevant for Forget, but keep in mind that the ! operator interacts with optional chaining, so having full support for it will probably require more than this, either in lowering or in HIR. E.g. assuming a and a.b are nullable, a?.b!.c is nullable despite the presence of the ! operator within the chain (with the null from a, but not from a.b), while (a?.b)!.c is not nullable and neither is a?.b?.c!. Mentioning this because I just discovered this and was surprised by it recently lol.

@josephsavona
Copy link
Contributor Author

@mvitousek Interesting! I definitely want to understand the rules behind that, some of those aren't intuitive.

In either case I was planning to hold off landing this until we explore building the nullability inference on top.

Hardanish-Singh

This comment was marked as off-topic.

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