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

Add a builtin for panic/crash #387

Open
Janiczek opened this issue Jun 10, 2024 · 0 comments
Open

Add a builtin for panic/crash #387

Janiczek opened this issue Jun 10, 2024 · 0 comments

Comments

@Janiczek
Copy link

Janiczek commented Jun 10, 2024

Opening this issue based on Discord discussion.

I'd like to have a way to crash at runtime. For example, Elm programs have Debug.todo which is sometimes useful.

I've tried to use the "cloning non-affine functions" method, but it doesn't work when you're using currying:

type Unit = Unit

panic _ =
  let nonaffine = @a (a,a)
  let boom = (nonaffine,nonaffine)
  (panic (Unit/Unit)) # doesn't work when we use `panic a = let ...; (panic a)`

# successfully crashes (ERROR: attempt to clone a non-affine global reference.)
Basics/append a b = (panic (Unit/Unit))

# doesn't work, hangs CPU
Basics/append = (panic (Unit/Unit))

main = (Basics/append "a" "b")
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

1 participant