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

Pattern match on uninitialized union simply chooses first branch #137

Open
rapha opened this issue Mar 8, 2017 · 1 comment
Open

Pattern match on uninitialized union simply chooses first branch #137

rapha opened this issue Mar 8, 2017 · 1 comment

Comments

@rapha
Copy link

rapha commented Mar 8, 2017

On the playground

use std

type u = union
        `Foo int
        `Bar
;;

const main = {
        var v : u

        match v
        | `Foo 123:    std.put("First branch\n")
        | `Foo x:      std.put("Got Foo {}\n", x)
        | `Bar:        std.put("Got Bar\n")
        ;;
}

Produces

Building
a.out...
	6m	-I /lib/myr in.myr 
	ld	-o a.out /lib/myr/_myrrt.o in.o -L/lib/myr -L/lib/myr -lstd -lsys 
First branch

But I would have expected a compile error.

@oridb
Copy link
Owner

oridb commented Mar 8, 2017

Yeah, there should definitely be a compile error.

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