ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

Enhance compiler error messages by surrounding types with single quotes

Open ghost opened this issue 6 years ago • 2 comments

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'

ghost avatar Dec 15 '18 16:12 ghost

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.

jemc avatar Dec 18 '18 17:12 jemc

I agree with @jemc.

aturley avatar Dec 18 '18 17:12 aturley