Skip to content

[minor] sigmatch errors should be sorted, for reproducible errors #13538

Closed
@timotheecour

Description

@timotheecour

I ran into this situation a few times; #13536 is also affected by it. sigmatch errors should be sorted so that unrelated code changes don't change such messages, which avoids having to re-write some tests

Example

t3330.nim(78, 4) Error: type mismatch: got <Bar[system.int]>
but expected one of:
proc test(foo: Foo[int])
  first type mismatch at position: 1
  required type for foo: Foo[int]
  but expression 'bar' is of type: Bar[system.int]
t3330.nim(63, 8) Hint: Non-matching candidates for add(k, string, T)
proc add(x: var string; y: string)
  first type mismatch at position: 1
  required type for x: var string
  but expression 'k' is of type: Alias
proc add[T](x: var seq[T]; y: openArray[T])
  first type mismatch at position: 1
  required type for x: var seq[T]
  but expression 'k' is of type: Alias
proc add(x: var string; y: cstring)
  first type mismatch at position: 1
  required type for x: var string
  but expression 'k' is of type: Alias
proc add[T](x: var seq[T]; y: T)
  first type mismatch at position: 1
  required type for x: var seq[T]
  but expression 'k' is of type: Alias
proc add(result: var string; x: float)
  first type mismatch at position: 1
  required type for result: var string
  but expression 'k' is of type: Alias
proc add(x: var string; y: char)
  first type mismatch at position: 1
  required type for x: var string
  but expression 'k' is of type: Alias
proc add(result: var string; x: int64)
  first type mismatch at position: 1
  required type for result: var string
  but expression 'k' is of type: Alias

t3330.nim(63, 8) template/generic instantiation of `add` from here
t3330.nim(70, 6) Foo: 'bar.value' cannot be assigned to
t3330.nim(63, 8) template/generic instantiation of `add` from here
t3330.nim(71, 6) Foo: 'bar.x' cannot be assigned to

expression: test(bar)'''

Expected Output

entries remain in the same order

Possible Solution

  • simply sort (by cmp[string]) the error messages for each sigmatch candidate

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