Giter Site home page Giter Site logo

Improve multiline errors about codespan HOT 9 CLOSED

brendanzab avatar brendanzab commented on May 25, 2024
Improve multiline errors

from codespan.

Comments (9)

lpil avatar lpil commented on May 25, 2024 1

I like 1 and 6 :)

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

Rustc tends to handle overlapping multiline errors cleverly too:

Screen Shot 2019-06-04 at 2 14 32 pm

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

Might be worth studying how https://github.com/rust-lang/rust/tree/961a9d6e97a37ff1bb33578721dfa8687054c7b8/src/librustc_errors does this

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

Here's another idea for primary spans:

   ┌── FizzBuzz.fun:4:13 ───
   │
 4 │   fizz₁ num = case (mod num 5) (mod num 3) of
   │ ╭─────────────^
 5 │ │     0 0 => "FizzBuzz"
 6 │ │     0 _ => "Fizz"
 7 │ │     _ 0 => "Buzz"
 8 │ │     _ _ => num
   │ ╰──────────────^ `case` clauses have incompatible types
   │

Not sure how to do secondary spans. This looks kinda weird:

   ┌── FizzBuzz.fun:4:13 ───
   │
 4 │   fizz₁ num = case (mod num 5) (mod num 3) of
   │ ╭─────────────-
 5 │ │     0 0 => "FizzBuzz"
 6 │ │     0 _ => "Fizz"
 7 │ │     _ 0 => "Buzz"
 8 │ │     _ _ => num
   │ ╰──────────────- `case` clauses have incompatible types
   │

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

I've decided to go with #77 (comment) in #98, but secondary spans still look kinda weird. Would appreciate some thoughts on alternatives!

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

Here are some options for secondary labels that I posted on #98 (comment):

  1. single: - multi:
    foo <$> bar
    --- ^^^ --- a label about `bar`
    
      fizz₁ num = case (mod num 5) (mod num 3) of
    ╭─────────────┘
    
  2. single: - multi:
    foo <$> bar
    --- ^^^ --- a label about `bar`
    
      fizz₁ num = case (mod num 5) (mod num 3) of
    ╭─────────────╯
    
  3. single: multi:
    foo <$> bar
    ‾‾‾ ^^^ ‾‾‾ a label about `bar`
    
      fizz₁ num = case (mod num 5) (mod num 3) of
    ╭─────────────‾
    
  4. single: ' multi: '
    foo <$> bar
    ''' ^^^ ''' a label about `bar`
    
      fizz₁ num = case (mod num 5) (mod num 3) of
    ╭─────────────'
    
  5. single: " multi: "
    foo <$> bar
    """ ^^^ """ a label about `bar`
    
      fizz₁ num = case (mod num 5) (mod num 3) of
    ╭─────────────"
    
  6. single: - multi: '
    foo <$> bar
    --- ^^^ --- a label about `bar`
    
      fizz₁ num = case (mod num 5) (mod num 3) of
    ╭─────────────'
    

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

I actually think I'm leaning towards the last one!

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

Yeah, I went with 6 in 46cf125 - willing to be swayed towards 1 however.

from codespan.

brendanzab avatar brendanzab commented on May 25, 2024

Closing this in favor of #100

from codespan.

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.