Skip to content

Improve error message when instantiating generics that lack a type #19882

@capocasa

Description

@capocasa

I wish this were a PR but I would require some guidance to where to start differentiating this error condition from others.

Improve error message when instantiating generics that lack a type

Example

import critbits
proc init(): ref CritBitTree =      
  new(result)
var a = init()

Current Output

 Error: cannot instantiate: 'CritBitTree'

Not helpful. Consider a programmer on a deadline after an all nighter at six in the morning. Shouldn't happen, but...

Expected Output

Error: cannot instantiate: 'CritBitTree'
Might the type definition be missing its concrete type, e.g. 'CritBitTree[void]' instead of 'CritBitTree'`?

Sleep deprived programmer now loves the compiler.

Possible Solution

Errors due to lacking concrete type would have to be isolated from other "cannot instantiate" error conditions and this message emitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions