brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 110 forks source link

Fix srcloc's tostring to be more informative #677

Open blerner opened 8 years ago

blerner commented 8 years ago

Currently we only have two outputs for srcloc: "line ##, column ##", or "file XXX: line ##, column ##". It would be nice to also show the extent of the srcloc, along the lines of "file:startLine:startCol--endLine:endCol". This can't be done with just the boolean flag we currently have, but making yet another method would be silly. Figure out how to streamline this into the existing code, while not breaking the compiler.

sorawee commented 8 years ago

Related: add one more field to srcloc to indicate elided frames.

blerner commented 8 years ago

No -- that's a problem for how stack traces are displayed; that has nothing to do with where the frames come from.

sorawee commented 8 years ago

Hmm, when performing TCO, I need to store this data somewhere. I think it's either srcloc or the stack frame itself. I don't know if modifying the existing stack frame is gonna be a good idea...

blerner commented 8 years ago

ABSOLUTELY in the stack frame. Source-locations are entirely static notions: they're used by error messages, parse trees, etc, and have nothing at all to do with the runtime behavior of the program. Please don't conflate the two.

sorawee commented 8 years ago

Got it!

peblair commented 8 years ago

If we're taking suggestions, I've always liked the way that Clang shows compiler errors (i.e. showing the actual line in question with a pointer to the error):

clang-error

(granted, this is more of a REPL display thing)