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

Suboptimal code for e is null #13247

Closed
alrz opened this Issue Aug 18, 2016 · 8 comments

Comments

@alrz
Contributor

alrz commented Aug 18, 2016

Currently e is null translates to an object.Equals call on master. The question is that (1) does it meant to be a shorthand for explicit reference null check (object)e == null? If so, (2) shouldn't it just translate to a ceq?

@orthoxerox

This comment has been minimized.

Contributor

orthoxerox commented Aug 19, 2016

What if e is a nullable value type? But I agree, the compiler can check this at compile time and emit better code for reference types.

@alrz alrz changed the title from Question: null patterns to Discussion: null patterns Aug 19, 2016

@gafter

This comment has been minimized.

Member

gafter commented Aug 19, 2016

@alrz they should generate the same code

@gafter gafter changed the title from Discussion: null patterns to Suboptimal code for e is null Aug 19, 2016

@gafter gafter added this to the 2.0 (Preview 5) milestone Aug 19, 2016

@gafter gafter self-assigned this Aug 19, 2016

@alrz

This comment has been minimized.

Contributor

alrz commented Aug 19, 2016

@gafter if so, I think this covers #8409 unless you have two non-constant expressions.

@jaredpar

This comment has been minimized.

Member

jaredpar commented Jan 12, 2017

Moving out for now as this doesn't meet the RTM bar.

@gafter

This comment has been minimized.

Member

gafter commented Jan 12, 2017

Did you want to move #16129 out too?

@gafter

This comment has been minimized.

Member

gafter commented Jan 12, 2017

Also #14252

@jaredpar

This comment has been minimized.

Member

jaredpar commented Jan 13, 2017

Yes and Yes. Thanks!

@jaredpar jaredpar removed this from the 15.1 milestone Mar 9, 2017

@gafter gafter added this to Next Up in Compiler: Gafter Mar 10, 2017

@gafter gafter assigned TyOverby and unassigned gafter Apr 18, 2017

@gafter gafter moved this from Next Up to First Priority in Compiler: Gafter Apr 18, 2017

@gafter gafter moved this from First Priority to Next Up in Compiler: Gafter May 5, 2017

@gafter gafter moved this from Next Up to Soon in Compiler: Gafter May 5, 2017

@gafter gafter moved this from Soon to Next Update in Compiler: Gafter May 16, 2017

@TyOverby TyOverby added this to Todo in Compiler: TyOverby May 22, 2017

@TyOverby TyOverby removed this from Todo in Compiler: TyOverby May 22, 2017

@sharwell

This comment has been minimized.

Member

sharwell commented May 26, 2017

💡 See #19803 for a very descriptive breakdown of the current and expected behavior for both Nullable<T> and reference types.

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