Commit Graph

17 Commits

Author SHA1 Message Date
metagn
f46f26e79a 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`](ab4278d217/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](18b5fb256d/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.
2024-01-17 11:59:54 +01:00
ringabout
cecaf9c56b fixes #22939; fixes #16890; push should but doesn't apply to importc … (#22944)
…var/let symbols


fixes #22939
fixes #16890

Besides, it was applied to let/const/var with pragmas, now it is
universally applied.

```nim
{.push exportc.}
proc foo =
  let bar = 12
  echo bar
{.pop.}
```

For example, the `bar` variable will be affected by `exportc`.
2023-11-19 17:53:25 +01:00
ringabout
078495c793 closes #16919; followup #16820, test tsugar on all backends (#22829)
closes #16919
followup #16820
2023-10-16 12:44:55 +08:00
ringabout
4fa86422c0 stdlib tests now check refc too (#21664)
* stdlib tests now check refc too

* typo

* fixes line numbers

* disable cpp

* do not touch
2023-04-21 15:37:58 +02:00
ringabout
2d9af2bd55 closes #20704; add a test case (#21480) 2023-03-06 17:34:41 +08:00
Vindaar
cc2b0f0172 [sugar] handle HiddenDeref in capture, error at CT if unsupported nnk (#20680)
* [sugar] handle HiddenDeref in capture, error at CT if unsupported nnk

Instead of running into trouble of the `.strVal` access failing, it's
better to error at CT.

* [tests] remove unnecessary import in test case

* improve ident extraction & extend test cases

* [tests] improve tests for `capture` of different types & act. check
2022-11-10 15:42:53 -05:00
ringabout
3d2f0e2c7c make more standard libraries work with nimPreviewSlimSystem (#20343)
* make more standard libraries work with `nimPreviewSlimSystem`

* typo

* part two

* Delete specutils.nim

* fixes more tests

* more fixes

* fixes tests

* fixes three more tests

* add formatfloat import

* fix

* last
2022-09-27 20:06:23 +02:00
hlaaftana
49ee2f7f3b fix #16967 [backport:1.2] (#16976)
* fix #16967 [backport:1.2]

* move test to tsugar
2021-02-09 13:04:36 +01:00
konsumlamm
f4449a897d Sugar tests (#16820) 2021-02-02 18:11:59 -08:00
Timothee Cour
4b2054a7bf dumpToString: improves on sugar.dump (#16841)
* dumpToString
* _
* fixup
* changelog
* address comment: removed the word "Deprecated"
2021-02-02 07:41:33 +01:00
flywind
6d442a40a6 use doAssert in tests (#16486) 2020-12-28 14:13:21 +01:00
Antonis Geralis
808ab7eae2 add collect with infered init, refs #16078 fixes #14332 (#16089)
* changelog
* add testcase, fixes #14332
2020-12-03 20:32:18 +01:00
flywind
bc1db0d6f1 move rest of tests to testament (#16140)
* move rest of tests to testament
* Update tests/stdlib/tsums.nim
2020-11-27 20:47:49 +01:00
cooldome
871d5e79b1 distinctBase type trait for distinct types (#13031) 2020-01-08 00:36:57 +01:00
Andreas Rumpf
e26545797e fixes #7816 (#11261) 2019-05-15 21:12:07 +02:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Timothee Cour
43f634db8d fixes #8519; implements T.distinctBase to reverse T = distinct A (#8531) 2018-08-10 09:20:14 +02:00