Coder Social home page Coder Social logo

Comments (3)

giacomocavalieri avatar giacomocavalieri commented on June 17, 2024 3

I've done some looking around and narrowed this down a bit if it can be of any help.
So a test that is producing the same crash is this one:

#[test]
fn this_crashes() {
    assert_warning!(
        r#"
pub type Returned(a) {
  Returned(List(a))
}

fn foo(user: Returned(#())) -> Int {
  let Returned([#()]) = user
  1
}
"#
    );
}

You don't get a crash if Returned doesn't have a generic (for example if you say its constructor is a fixed Returned(List(#())))

The problem is that, when doing the exhaustiveness checking, it ends up running into a type variable (the Returned one) and branch_mode decides that is Infinite and the you run into the tuple pattern and get the crash.

Funnily enough, if you remove the list and just do:

pub type Returned(a) {
  Returned(a)
}

fn foo(user: Returned(#())) -> Int {
  let Returned(#()) = user
  1
}

You don't get the crash anymore, so I'm guessing it might have to do with how list patterns are handled. I'm not really familiar with the algorithm so I couldn't actually fix the bug but maybe this can be of help

(Huge thanks to @DanielSherlock for helping me out!)

from gleam.

lpil avatar lpil commented on June 17, 2024

Thank you

from gleam.

lpil avatar lpil commented on June 17, 2024

Oops! Found another bug

from gleam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.