Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

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

Closed
CeylonMigrationBot opened this issue Jan 16, 2015 · 7 comments
Closed

Comments

@CeylonMigrationBot
Copy link

[@lucaswerkmeister] ```ceylon
shared void run() {
value c = switch (0) case (0) smaller case (1) equal else nothing;
}

> source/tmp/run.ceylon:2: error: incompatible types
```ceylon
    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.

[Migrated from ceylon/ceylon-compiler#2001]
[Closed at 2015-01-19 12:17:12]

@CeylonMigrationBot
Copy link
Author

[@tombentley] The problem here was that the type of the switch is these days smaller|equal (as a result of #3971) 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 ?

@CeylonMigrationBot
Copy link
Author

[@gavinking] 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 #3971) 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.

@CeylonMigrationBot
Copy link
Author

[@tombentley]

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?

@CeylonMigrationBot
Copy link
Author

[@gavinking] @tombentley read again what I just wrote :)

@CeylonMigrationBot
Copy link
Author

[@gavinking] Hint: there are no type args in the above code!

@CeylonMigrationBot
Copy link
Author

[@tombentley] 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.

@CeylonMigrationBot
Copy link
Author

[@gavinking] 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants