diff options
author | metagn <metagngn@gmail.com> | 2024-01-17 13:59:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-17 11:59:54 +0100 |
commit | f46f26e79aada7195f4d83d8601f0d856520763d (patch) | |
tree | e6d7d5339bb57a088fe64e3b386eef5ef0353184 /tests/concepts/tconcepts_issues.nim | |
parent | 18b5fb256d4647efa6a64df451d37129d36e96f3 (diff) | |
download | Nim-f46f26e79aada7195f4d83d8601f0d856520763d.tar.gz |
don't use previous bindings of `auto` for routine return types (#23207)
fixes #23200, fixes #18866 #21065 made it so `auto` proc return types remained as `tyAnything` and not turned to `tyUntyped`. This had the side effect that anything previously bound to `tyAnything` in the proc type match was then bound to the proc return type, which is wrong since we don't know the proc return type even if we know the expected parameter types (`tyUntyped` also [does not care about its previous bindings in `typeRel`](https://github.com/nim-lang/Nim/blob/ab4278d2179639f19967431a7aa1be858046f7a7/compiler/sigmatch.nim#L1059-L1061) maybe for this reason). Now we mark `tyAnything` return types for routines as `tfRetType` [as done for other meta return types](https://github.com/nim-lang/Nim/blob/18b5fb256d4647efa6a64df451d37129d36e96f3/compiler/semtypes.nim#L1451), and ignore bindings to `tyAnything` + `tfRetType` types in `semtypinst`. On top of this, we reset the type relation in `paramTypesMatch` only after creating the instantiation (instead of trusting `isInferred`/`isInferredConvertible` before creating the instantiation), using the same mechanism that `isBothMetaConvertible` uses. This fixes the issues as well as making the disabled t15386_2 test introduced in #21065 work. As seen in the changes for the other tests, the error messages give an obscure `proc (a: GenericParam): auto` now, but it does give the correct error that the overload doesn't match instead of matching the overload pre-emptively and expecting a specific return type. tsugar had to be changed due to #16906, which is the problem where `void` is not inferred in the case where `result` was never touched.
Diffstat (limited to 'tests/concepts/tconcepts_issues.nim')
-rw-r--r-- | tests/concepts/tconcepts_issues.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/concepts/tconcepts_issues.nim b/tests/concepts/tconcepts_issues.nim index 1d5e415dd..d6c8674fd 100644 --- a/tests/concepts/tconcepts_issues.nim +++ b/tests/concepts/tconcepts_issues.nim @@ -510,7 +510,7 @@ proc depthOf*[V](orderType: typedesc[BreadthOrder], tree: AnyTree[V], root, goal if root == goal: return 0 var order = init[LevelNode[V]](orderType) - order.expand(tree, root, (leaf) => (1, leaf)) + order.expand(tree, root, (leaf) => (1.uint, leaf)) while order.hasNext(): let depthNode: LevelNode[V] = order.popNext() if depthNode.node == goal: |