Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression from version-1-6 to version-2-0/version-2-2/devel with mutually recursive functions and Error: n(t) can raise an unlisted exception: Exception #24765

Open
tersec opened this issue Mar 11, 2025 · 4 comments
Assignees

Comments

@tersec
Copy link
Contributor

tersec commented Mar 11, 2025

Nim Version

Builds and runs:

Nim Compiler Version 1.6.21 [Linux: amd64]
Compiled at 2025-03-10
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: ec324ad0736c3e0cfa26b64d6631b15693633a6f
active boot switches: -d:release

Does not bulid:

Nim Compiler Version 2.0.15 [Linux: amd64]
Compiled at 2025-03-10
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 41637db18f6a82df4a92f2e00a780e5815d17028
active boot switches: -d:release
Nim Compiler Version 2.2.3 [Linux: amd64]
Compiled at 2025-03-10
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 9cf0d07b9e1e21ecbee8796bda7d3cedb9196dc9
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-03-10
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: f8294ce06e61752d15624e0422c5296292ef5467
active boot switches: -d:release

Description

proc n(d: var int)

proc s(p: int|int) {.raises: [CatchableError].} =
  var t: int
  if false: n(t)

proc n(d: var int) = s(0)

Current Output

/tmp/w.nim(7, 23) template/generic instantiation of `s` from here
/tmp/w.nim(3, 30) template/generic instantiation from here
/tmp/w.nim(5, 14) Error: n(t) can raise an unlisted exception: Exception

Expected Output


Known Workarounds

No response

Additional Information

No response

@metagn
Copy link
Collaborator

metagn commented Mar 11, 2025

!nim c

proc n(d: var int)

proc s(p: int|int) {.raises: [CatchableError].} =
  var t: int
  if false: n(t)

proc n(d: var int) = s(0)

Copy link
Contributor

🐧 Linux bisect by @metagn (collaborator)
devel 👎 FAIL

Output


Filesize 0 (0 bytes)
Duration

stable 👎 FAIL

Output


Filesize 0 (0 bytes)
Duration

2.2.2 👎 FAIL

Output


Filesize 0 (0 bytes)
Duration

2.0.0 👎 FAIL

Output


Filesize 0 (0 bytes)
Duration

1.6.20 👍 OK

Output


Filesize 95.50 Kb (97,792 bytes)
Duration

1.4.8 👍 OK

Output


Filesize 91.16 Kb (93,344 bytes)
Duration

1.2.18 👍 OK

Output


Filesize 86.88 Kb (88,968 bytes)
Duration

1.0.10 👍 OK

Output


Filesize 81.98 Kb (83,952 bytes)
Duration

#1e15f975b ➡️ 🐛

Diagnostics

ringabout introduced a bug at 2022-10-15 20:07:40 +0800 on commit #1e15f975b with message:


The bug is in the files:


The bug can be in the commits:

(Diagnostics sometimes off-by-one).

Stats
  • GCC 13.3.0
  • Clang 18.1.3
  • NodeJS 18.3
  • Created 2025-03-11T09:49:24Z
  • Comments 1
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

🤖 Bug found in 23 mins bisecting 2809 commits at 119 commits per second

@ringabout ringabout self-assigned this Mar 11, 2025
@ringabout
Copy link
Member

ringabout commented Mar 11, 2025

It seems to be an issue of strictEffects

@metagn
Copy link
Collaborator

metagn commented Mar 11, 2025

Probably specifically because of these lines:

Nim/compiler/sempass2.nim

Lines 1036 to 1038 in 850f327

if laxEffects notin tracked.c.config.legacyFeatures and a.kind == nkSym and
a.sym.kind in routineKinds:
propagateEffects(tracked, n, a.sym)

By the time s is getting instantiated, n is no longer marked as a forward proc but still does not have a built effect list. Previously, without strictEffects, this case would just be ignored. So this now fails because strictEffects is always enabled, it should work with --legacy:laxEffects. Given that this works as expected though, maybe there is a fix here unlike #24766:

proc n() =
  if false:
    n()

proc foo() {.raises: [CatchableError].} =
  n()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants