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

halt return type gets in the way #33

Open
phrodo00 opened this issue Jun 12, 2018 · 1 comment
Open

halt return type gets in the way #33

phrodo00 opened this issue Jun 12, 2018 · 1 comment

Comments

@phrodo00
Copy link

Since halt doesn't return, it should return Nothing. This can be accomplished by throwing the result of java's halt (it won't actually get thrown because java's halt will do it first).

This will let us use halt inside of when and the like without affecting the type of the expression. (right now, since halt returns the exception, a when statement will change its type to Any for no good reason)

@Mee42
Copy link

Mee42 commented Nov 23, 2018

On another note, could we have HaltException extend Exception instead of RuntimeException, so the compiler can smart-cast T? objects to non-nullable T objects in some places

ex:

val x :Int? = null
if(x == null)
    halt(400,"x is null")
x.toString()//and other methods, because x is of type Int not Int?```

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

No branches or pull requests

2 participants