Skip to content

generic-as-typeclass is not considered to be more specific than tuple or object #1525

Open
@alaviss

Description

@alaviss

Example

test.nim:

import test2

discard O[int](data: 10) == O[int](data: 10)

test2.nim:

type
  O*[T] = object
    data*: T

func `==`*[T, U: O](a: T, b: U): bool =
  when T is U:
    system.`==`(a, b)
  else:
    false

Actual Output

test.nim(3, 26) Error: ambiguous call; both system.==(x: T: tuple or object, y: T: tuple or object) [proc declared in nimskull/0.1.0-dev.21458/lib/system.nim(1811, 6)] and test2.==(a: T: O, b: U: O) [func declared in test2.nim(5, 6)] match for: (O[system.int], O[system.int])

Expected Output

Should compile and use test2.`==`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler/semRelated to semantic-analysis system of the compiler

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions