Comments (9)
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.
Thank you!
from gleam.
I'm taking a look! 👀
from gleam.
Thank you! What do you think the error ought to be?
from gleam.
@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.
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.
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.
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.
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)
- LSP code action: fill case arms HOT 2
- LSP: narrow complete suggestions after a pipe HOT 1
- LSP: Suggestion on record accessors HOT 2
- LSP: Crash on type redefine HOT 4
- "Else" type variant causes erlang troubles HOT 1
- Option to suppress gleam cli's log messages HOT 1
- Certain code causes a function to not be generated even after passing type checking HOT 2
- LSP Code Action: Convert function callback into `use` statement HOT 1
- False negative diagnostic for unused (aliased) imports HOT 3
- LSP Code Action: Desugar `use` expression
- Invalid Erlang generated with shadowed variables in bit patterns
- Compile error on Windows HOT 3
- Consider adding a flag to the formatter to force an output produced by a specific version HOT 3
- LSP: Show auto-complete types instead of the module names HOT 1
- Add warning for when publishing a package that uses `@target`
- unknown type HOT 1
- Unimplemented function? HOT 1
- `use` in combination with pipelines produces a confusing type error HOT 4
- Language Server Crashes when custom type is not defined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gleam.