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

Match with autocast should work on primitive types #760

Closed
nddrylliog opened this issue Jan 3, 2014 · 3 comments
Closed

Match with autocast should work on primitive types #760

nddrylliog opened this issue Jan 3, 2014 · 3 comments

Comments

@nddrylliog
Copy link
Member

Example:

a: Int
a = 12
b := match (a) {
        case str: String => "String"
        case num: Int => "Int"
        case => "unknown"
}
"b: %s" printfln(b)

Currently that crashes, as 'a' is cast to an object for some reason. Note that we could be a smart compiler and just yank the rest of the cases - actually it's not very useful code, but there's no reason why it should crash.

@fasterthanlime
Copy link
Collaborator

Ok so here's a shorter one - apparently covers still inherit from object, which has instanceOf, so this crashes as well:

v := 12 instanceOf?(Object)
"12 is object? #{v}" println()

@fasterthanlime
Copy link
Collaborator

But here's the thing - I kinda think instanceOf should work even on covers, because it's a bit special, like an operator (like new) - that would fix the match case (ha!).

@fasterthanlime
Copy link
Collaborator

Interesting side problem, while fixing, I discovered that

12 class inheritsFrom?(Object)

Evaluates to true.

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

No branches or pull requests

2 participants