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

Comments

Projects
None yet
2 participants
@nddrylliog
Member

nddrylliog commented Jan 3, 2014

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

This comment has been minimized.

Collaborator

fasterthanlime commented Aug 17, 2014

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

This comment has been minimized.

Collaborator

fasterthanlime commented Aug 17, 2014

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

This comment has been minimized.

Collaborator

fasterthanlime commented Aug 17, 2014

Interesting side problem, while fixing, I discovered that

12 class inheritsFrom?(Object)

Evaluates to true.

fasterthanlime added a commit that referenced this issue Aug 17, 2014

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