fixes-25655; defining >= operator generates compile error (#25787)

Fixes https://github.com/nim-lang/Nim/issues/25655

---------

Co-authored-by: Andreas Rumpf <araq4k@proton.me>
This commit is contained in:
Tomohiro
2026-06-08 16:00:00 +09:00
committed by GitHub
parent f5930d0bb3
commit 9b80b2e868
6 changed files with 43 additions and 6 deletions

View File

@@ -0,0 +1,12 @@
discard """
cmd: "nim check $file"
action: compile
nimout: '''
tinvalid_cmp_op1.nim(12, 1) Warning: define `<=` instead of `>=` to implement user defined comparison operator. it allows you to use `>=` automatically. [InvalidCmpOp]
'''
"""
# issue #25655
type Foo = distinct int
func `>=`(a, b: Foo): bool = int(a) >= int(b)

View File

@@ -0,0 +1,12 @@
discard """
cmd: "nim check $file"
action: compile
nimout: '''
tinvalid_cmp_op2.nim(12, 1) Warning: define `<` instead of `>` to implement user defined comparison operator. it allows you to use `>` automatically. [InvalidCmpOp]
'''
"""
# issue #25655
type Foo = distinct int
func `>`(a, b: Foo): bool = int(a) > int(b)

View File

@@ -0,0 +1,12 @@
discard """
cmd: "nim check $file"
action: compile
nimout: '''
tinvalid_cmp_op3.nim(12, 1) Warning: define `==` instead of `!=` to implement user defined comparison operator. it allows you to use `!=` automatically. [InvalidCmpOp]
'''
"""
# issue #25655
type Foo = distinct int
func `!=`(a, b: Foo): bool = int(a) != int(b)