Skip to content

Pattern match on uninitialized union simply chooses first branch #137

@rapha

Description

@rapha

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions