Skip to content

Commit 16aa10d

Browse files
committed
fixes #10038; deprecate generic methods, they are unreliable
1 parent 36a398d commit 16aa10d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
tree from the symbol declaration instead of just the initializer portion.
3434

3535
- To use multi-methods, explicit `--multimethods:on` is now needed.
36+
- Generic methods are now deprecated; they never worked well.
3637

3738
- Compile time checks for integer and float conversions are now stricter.
3839
For example, `const x = uint32(-1)` now gives a compile time error instead
@@ -45,7 +46,8 @@
4546
- A bug allowed `macro foo(): int = 123` to compile even though a
4647
macros has to return a `NimNode`. This has been fixed.
4748

48-
- With the exception of `uint` and `uint64`, conversion to unsigned types are now range checked during runtime.
49+
- With the exception of `uint` and `uint64`, conversion to unsigned types
50+
are now range checked during runtime.
4951

5052
#### Breaking changes in the standard library
5153

compiler/semstmts.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,8 +1712,9 @@ proc semMethodPrototype(c: PContext; s: PSym; n: PNode) =
17121712
if x.kind == tyObject and t.len-1 == n.sons[genericParamsPos].len:
17131713
foundObj = true
17141714
x.methods.add((col,s))
1715-
if not foundObj:
1716-
message(c.config, n.info, warnDeprecated, "generic method not attachable to object type is deprecated")
1715+
message(c.config, n.info, warnDeprecated, "generic methods are deprecated")
1716+
#if not foundObj:
1717+
# message(c.config, n.info, warnDeprecated, "generic method not attachable to object type is deprecated")
17171718
else:
17181719
# why check for the body? bug #2400 has none. Checking for sfForward makes
17191720
# no sense either.

doc/manual.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,6 +3526,8 @@ the effects that a call to ``m`` might cause.
35263526

35273527
**Note**: Compile-time execution is not (yet) supported for methods.
35283528

3529+
**Note**: Starting from Nim 0.20, generic methods are deprecated.
3530+
35293531

35303532
Inhibit dynamic method resolution via procCall
35313533
-----------------------------------------------

0 commit comments

Comments
 (0)