summary refs log tree commit diff stats
path: root/changelogs
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-04-11 10:23:41 +0300
committerGitHub <noreply@github.com>2023-04-11 09:23:41 +0200
commit1bb117cd7a49954832d21e6a1502492770acb77b (patch)
tree299cbbc13c72d8f0e3844a1c9770874a25050a67 /changelogs
parent420b0c14eb0b82e05873191b277e889f95bc802b (diff)
downloadNim-1bb117cd7a49954832d21e6a1502492770acb77b.tar.gz
`proc` typeclass accounts for `iterator`, call conventions + `nil` fix + document typeclass AST (#21629)
* test fix #16546 #16548 + another issue

* please don't tell me other packages do this

* fix CI + test typeclass callconv pragma

* better logic in parser

* docs and changelog
Diffstat (limited to 'changelogs')
-rw-r--r--changelogs/changelog_2_0_0.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/changelogs/changelog_2_0_0.md b/changelogs/changelog_2_0_0.md
index 60b380d12..bef5f6073 100644
--- a/changelogs/changelog_2_0_0.md
+++ b/changelogs/changelog_2_0_0.md
@@ -175,6 +175,40 @@
 
 - - Added the `--legacy:verboseTypeMismatch` switch to get legacy type mismatch error messages.
 
+- The `proc` and `iterator` type classes now respectively only match
+  procs and iterators. Previously both type classes matched any of
+  procs or iterators.
+
+  ```nim
+  proc prc(): int =
+    123
+
+  iterator iter(): int =
+    yield 123
+  
+  proc takesProc[T: proc](x: T) = discard
+  proc takesIter[T: iterator](x: T) = discard
+
+  # always compiled:
+  takesProc(prc)
+  takesIter(iter)
+  # no longer compiles:
+  takesProc(iter)
+  takesIter(prc)
+  ```
+
+- The `proc` and `iterator` type classes now accept a calling convention pragma
+  (i.e. `proc {.closure.}`) that must be shared by matching proc or iterator
+  types. Previously pragmas were parsed but discarded if no parameter list
+  was given.
+
+  This is represented in the AST by an `nnkProcTy`/`nnkIteratorTy` node with
+  an `nnkEmpty` node in the place of the `nnkFormalParams` node, and the pragma
+  node in the same place as in a concrete `proc` or `iterator` type node. This
+  state of the AST may be unexpected to existing code, both due to the
+  replacement of the `nnkFormalParams` node as well as having child nodes
+  unlike other type class AST.
+
 ## Standard library additions and changes
 
 [//]: # "Changes:"