summary refs log tree commit diff stats
path: root/testament
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-04-09 15:37:34 +0300
committerGitHub <noreply@github.com>2024-04-09 14:37:34 +0200
commit73b0b0d31c156392c64b8b088402695c7e27f0f0 (patch)
tree21565506254945626654bbf46de46fffe4bd4f52 /testament
parentc23d6a3cb92a7f4d4a96691148359b917c55d2af (diff)
downloadNim-73b0b0d31c156392c64b8b088402695c7e27f0f0.tar.gz
stop gensym identifiers hijacking routine decl names in templates (#23392)
fixes #23326

In a routine declaration node in a template, if the routine is marked as
`gensym`, the compiler adds it as a new symbol to a preliminary scope of
the template. If it's not marked as gensym, then it searches the
preliminary scope of the template for the name of the routine, then when
it matches a template parameter or a gensym identifier, the compiler
replaces the name node with a symbol node of the found symbol.

This makes sense for the template parameter since it has to be replaced
later, but not really for the gensym identifier, as it doesn't allow us
to inject a routine with the same name as an identifier previously
declared as gensym (the problem in #23326 is when this is in another
`when` branch).

However this is the only channel to reuse a gensym symbol in a
declaration, so maybe removing it has side effects. For example if we
have:

```nim
proc foo(x: int) {.gensym.} = discard
proc foo(x: float) {.gensym.} = discard
```

it will not behave the same as

```nim
proc foo(x: int) {.gensym.} = discard
proc foo(x: float) = discard
```

behaved previously, which maybe allowed overloading over the gensym'd
symbols.

A note to the "undeclared identifier" error message has also been added
for a potential error code that implicitly depended on the old behavior
might give, namely ``undeclared identifier: 'abc`gensym123'``, which
happens when in a template an identifier is first declared gensym in
code that doesn't compile, then as a routine which injects by default,
then the identifier is used.
Diffstat (limited to 'testament')
-rw-r--r--testament/important_packages.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/testament/important_packages.nim b/testament/important_packages.nim
index b9f891dad..7a2d2f7df 100644
--- a/testament/important_packages.nim
+++ b/testament/important_packages.nim
@@ -60,7 +60,7 @@ pkg "compactdict"
 pkg "comprehension", "nimble test", "https://github.com/alehander92/comprehension"
 pkg "cowstrings"
 pkg "criterion", allowFailure = true # needs testing binary
-pkg "datamancer"
+pkg "datamancer", "nimble install -y arraymancer@#HEAD; nimble test"
 pkg "dashing", "nim c tests/functional.nim"
 pkg "delaunay"
 pkg "docopt"
@@ -72,7 +72,7 @@ pkg "fragments", "nim c -r fragments/dsl.nim", allowFailure = true # pending htt
 pkg "fusion"
 pkg "gara"
 pkg "glob"
-pkg "ggplotnim", "nim c -d:noCairo -r tests/tests.nim"
+pkg "ggplotnim", "nimble install -y arraymancer@#HEAD; nim c -d:noCairo -r tests/tests.nim"
 pkg "gittyup", "nimble test", "https://github.com/disruptek/gittyup", allowFailure = true
 pkg "gnuplot", "nim c gnuplot.nim"
 # pkg "gram", "nim c -r --mm:arc --define:danger tests/test.nim", "https://github.com/disruptek/gram"
@@ -125,7 +125,7 @@ pkg "nimx", "nim c test/main.nim", allowFailure = true
 pkg "nitter", "nim c src/nitter.nim", "https://github.com/zedeus/nitter"
 pkg "norm", "testament r tests/common/tmodel.nim"
 pkg "npeg", "nimble testarc"
-pkg "numericalnim", "nimble nimCI"
+pkg "numericalnim", "nimble install -y arraymancer@#HEAD; nimble nimCI"
 pkg "optionsutils"
 pkg "ormin", "nim c -o:orminn ormin.nim"
 pkg "parsetoml"