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

Incompatible type of nothing in switch expression with object cases #2001

Closed
lucaswerkmeister opened this issue Jan 16, 2015 · 7 comments
Closed
Assignees
Labels
Milestone

Comments

@lucaswerkmeister
Copy link
Member

shared void run() {
    value c = switch (0) case (0) smaller case (1) equal else nothing;
}

source/tmp/run.ceylon:2: error: incompatible types

    value c = switch (0) case (0) smaller case (1) equal else nothing;
                                                              ^

required: Comparison
found: Object

The error disappears if both cases evaluate to the same object (e. g. case (1) smaller); in that case, the compiler casts nothing to smaller_.

As always, generated code, @noanno’ed.

@gavinking gavinking added the BUG label Jan 16, 2015
@gavinking gavinking added this to the 1.1.5 milestone Jan 16, 2015
@tombentley tombentley self-assigned this Jan 19, 2015
@tombentley
Copy link
Member

The problem here was that the type of the switch is these days smaller|equal (as a result of ceylon/ceylon-spec#865) so I suppose I need to add a denoteableType() call somewhere.

My concern is that denoteableType() is going to see liberal use through the code generator as we see more of this sort of bug. I don't know whether there's a right or a wrong place to call denoteableType(), because aren't we supposed to reify types like smaller|equal ?

@gavinking
Copy link
Member

We only reify them when they are type args, and according to the spec such types are never inferred.

Sent from my iPhone

On 19 Jan 2015, at 12:28, Tom Bentley notifications@github.com wrote:

The problem here was that the type of the switch is these days smaller|equal (as a result of ceylon/ceylon-spec#865) so I suppose I need to add a denoteableType() call somewhere.

My concern is that denoteableType() is going to see liberal use through the code generator as we see more of this sort of bug. I don't know whether there's a right or a wrong place to call denoteableType(), because aren't we supposed to reify types like smaller|equal ?


Reply to this email directly or view it on GitHub.

@tombentley
Copy link
Member

We only reify them when they are type args

Right. So when constructing a reified type argument I need to ensure I'm not using a denotableType()-ed type. But otherwise I can use denotableType() freely.

according to the spec such types are never inferred.

So does that mean this bug is a typechecker bug?

@gavinking
Copy link
Member

@tombentley read again what I just wrote :)

@gavinking
Copy link
Member

Hint: there are no type args in the above code!

tombentley added a commit that referenced this issue Jan 19, 2015
tombentley added a commit that referenced this issue Jan 19, 2015
@tombentley
Copy link
Member

I assume that means it's not a typechecker bug, and we can expect to find this foo|bar stuff everywhere except for stuff like value and implicit values like for variables.

@gavinking
Copy link
Member

No, it's not a bug, and yes, the backend needs to be able to accommodate expressions with types like this.

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

No branches or pull requests

3 participants