ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.68k stars 409 forks source link

Enhance compiler error messages by surrounding types with single quotes #2960

Open ghost opened 5 years ago

ghost commented 5 years ago
Error:
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:45:27: argument not a subtype of parameter
        ClosedDoor.openIt(_logger)
                          ^
Info:
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:45:27: argument type is this->PrimitiveOutStreamLogger ref
        ClosedDoor.openIt(_logger)
                              ^
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:20:14: parameter type is Logger val
        fun openIt(logger: Logger val) =>
                 ^
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:28:16: PrimitiveOutStreamLogger box is not a subtype of Logger val: box is not a subcap of val
        let _logger: PrimitiveOutStreamLogger

I'm currently in the process of learning Pony and while doing so I stumbled across these error messages. (Object / Class) Types mentioned are kinda hard to read and distinguish between actual source code and the error message.

I'd suggest that (object / class) types are boxed with single quotes. That would look something like this:

Error:
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:45:27: argument not a subtype of parameter
        'ClosedDoor.openIt(_logger)'
                          ^
Info:
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:45:27: argument type is 'this->PrimitiveOutStreamLogger ref'
        'ClosedDoor.openIt(_logger)'
                              ^
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:20:14: parameter type is 'Logger val'
        'fun openIt(logger: Logger val) =>'
                 ^
/home/shad0wcore/PonyProjects/LearningPony/PrimitivesAndEnumerations/main.pony:28:16: 'PrimitiveOutStreamLogger box' is not a subtype of 'Logger val': 'box' is not a subcap of 'val'
        'let _logger: PrimitiveOutStreamLogger'
jemc commented 5 years ago

I think it's fine to put some kind of quotes around the nominal type in the error description, but I'd be opposed to putting quotes around the code snippet showing the source code where the error is.

As far as the style of quote used for the type name, I might suggest backticks (a la markdown) instead of single quotes.

aturley commented 5 years ago

I agree with @jemc.