Coder Social home page Coder Social logo

Comments (9)

sajorobinson avatar sajorobinson commented on June 29, 2024 1

Something I noticed is the way the error is presented, it seems like it's supposed to be an unordered list of possible things it's expecting.

I think I would have interpreted its meaning more quickly if it looked like:

Expected one of:

- "}"
- A record constructor

or, if markdown unordered lists aren't desirable, something using indents like:

Expected one of:

    "}"
    A record constructor

from gleam.

lpil avatar lpil commented on June 29, 2024

Thank you!

from gleam.

rdghosal avatar rdghosal commented on June 29, 2024

I'm taking a look! 👀

from gleam.

lpil avatar lpil commented on June 29, 2024

Thank you! What do you think the error ought to be?

from gleam.

rdghosal avatar rdghosal commented on June 29, 2024

@lpil I think that "a record constructor" and the message contents are pretty descriptive, but I think a change in formatting could improve readability.

I'm currently working on changing this error message to look something like the following... What do you think?
(Note, the expected tokens will indeed be inlined as shown.)

Expected a "}" or a record constructor

from gleam.

rdghosal avatar rdghosal commented on June 29, 2024

Agreed; if we go with a list, there needs to be something that denotes list items (the capital "A" in "A record" is a nice touch too).

Also, I noticed that my proposed solution results in horizontal growth of the error message, though, in practice, this shouldn't be an issue. I suppose it's a matter of preference...

from gleam.

lpil avatar lpil commented on June 29, 2024

Seeing as this is a common mistake perhaps we could show what the correct code should be. We could use the name of the type as the name of the constructor we display

from gleam.

lpil avatar lpil commented on June 29, 2024
pub type User {
  name: String
}
error: Syntax error
   ┌─ /Users/louis/src/lpil/puck/src/puck.gleam:23:3
   │
23 │   name: String
   │   ^^^^ I was not expecting this

Each custom type variant must have a constructor:

    pub type User {
      User(
        name: String,
      )
    }

from gleam.

rdghosal avatar rdghosal commented on June 29, 2024

Ooo, that's a great idea 👌

I'll see if I can fold in a similar approach for other instances of unexpected tokens.

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.