fixes #10038; deprecate generic methods, they are unreliable

This commit is contained in:
Andreas Rumpf
2019-05-25 23:56:16 +02:00
parent 36a398d96f
commit 16aa10dfe1
3 changed files with 8 additions and 3 deletions

View File

@@ -33,6 +33,7 @@
tree from the symbol declaration instead of just the initializer portion.
- To use multi-methods, explicit `--multimethods:on` is now needed.
- Generic methods are now deprecated; they never worked well.
- Compile time checks for integer and float conversions are now stricter.
For example, `const x = uint32(-1)` now gives a compile time error instead
@@ -45,7 +46,8 @@
- A bug allowed `macro foo(): int = 123` to compile even though a
macros has to return a `NimNode`. This has been fixed.
- With the exception of `uint` and `uint64`, conversion to unsigned types are now range checked during runtime.
- With the exception of `uint` and `uint64`, conversion to unsigned types
are now range checked during runtime.
#### Breaking changes in the standard library

View File

@@ -1712,8 +1712,9 @@ proc semMethodPrototype(c: PContext; s: PSym; n: PNode) =
if x.kind == tyObject and t.len-1 == n.sons[genericParamsPos].len:
foundObj = true
x.methods.add((col,s))
if not foundObj:
message(c.config, n.info, warnDeprecated, "generic method not attachable to object type is deprecated")
message(c.config, n.info, warnDeprecated, "generic methods are deprecated")
#if not foundObj:
# message(c.config, n.info, warnDeprecated, "generic method not attachable to object type is deprecated")
else:
# why check for the body? bug #2400 has none. Checking for sfForward makes
# no sense either.

View File

@@ -3526,6 +3526,8 @@ the effects that a call to ``m`` might cause.
**Note**: Compile-time execution is not (yet) supported for methods.
**Note**: Starting from Nim 0.20, generic methods are deprecated.
Inhibit dynamic method resolution via procCall
-----------------------------------------------