Skip to content

Concept: explanation for invalid predicate is pointing to the wrong line #19561

Open
@Menduist

Description

@Menduist

Example

type
  Concept {.explain.} = concept x
    x is not bool
    x is not bool
    x is string

proc test(c: Concept) = echo "ok"
test(5)

Current Output

/tmp/test.nim(8, 5) Error: type mismatch: got <int literal(5)>
but expected one of:
proc test(c: Concept)
  first type mismatch at position: 1
  required type for c: Concept
  but expression '5' is of type: int literal(5)
/tmp/test.nim(3, 5) Concept: concept predicate failed

expression: test(5)

This message doesn't actually point to the failed predicate, line 3 is x is not bool, which is true

Expected Output

/tmp/test.nim(5, 5) Concept: concept predicate failed

Line 5 is x is string, the actual failure

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions