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

Compiler crash on exhaustive match where last case is a union subset. #2048

Closed
Perelandric opened this issue Jul 15, 2017 · 1 comment
Closed
Assignees

Comments

@Perelandric
Copy link
Contributor

Perelandric commented Jul 15, 2017

(Maybe related to #2028 ?)

Given this start of a program that uses a Tester class:

use "debug"

actor Main
  new create(env: Env) => Tester.test()
    
primitive Foo
primitive Bar

type Foobar is (Foo | Bar)

The following two definitions of Tester segfault the compiler:

https://is.gd/jgPLZL

class Tester
  fun test() =>
    let part: (Foobar |  None) = None

    match part
    | None => Debug("none")
    | let c': Foobar => Debug("Foobar")
    end

https://is.gd/cgfwRR

class Tester
  fun test() =>
    let part: ((Foobar, Foo) |  None) = None

    match part
    | None => Debug("none")
    | (let c': Foobar, let ss': Foo) => Debug("Foobar")
    end

EDIT: The error for this one is fixed on master via #2002, so that makes this identical to the one above.

And this one resulted in a compile-time error with the 0.15.0 tagged release, but segfaults the compiler on the master branch:

https://is.gd/DUdo1i

class Tester
  fun test() =>
    let part: (Foobar |  None) = None

    match part
    | None => Debug("none")
    | (let c': Foobar) => Debug("Foobar") // Note the parens around the `let` declaration
    end
@jemc
Copy link
Member

jemc commented Jul 15, 2017

This turns out to be a pretty simple fix once I found the problematic code. You found an edge case I wasn't accounting for in the codegen for exhaustive match.

@jemc jemc changed the title Segfaults with matching on subset of union type Compiler crash on exhaustive match where last case is a union subset. Jul 15, 2017
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