Files
Nim/compiler
metagn 42e8472ca6 fix noreturn/implicit discard check logic (#23681)
fixes #10440, fixes #13871, fixes #14665, fixes #19672, fixes #23677

The false positive in #23677 was caused by behavior in
`implicitlyDiscardable` where only the last node of `if`/`case`/`try`
etc expressions were considered, as in the final node of the final
branch (in this case `else`). To fix this we use the same iteration in
`implicitlyDiscardable` that we use in `endsInNoReturn`, with the
difference that for an `if`/`case`/`try` statement to be implicitly
discardable, all of its branches must be implicitly discardable.
`noreturn` calls are also considered implicitly discardable for this
reason, otherwise stuff like `if true: discardableCall() else: error()`
doesn't compile.

However `endsInNoReturn` also had bugs, one where `finally` was
considered in noreturn checking when it shouldn't, another where only
`nkIfStmt` was checked and not `nkIfExpr`, and the node given for the
error message was bad. So `endsInNoReturn` now skips over
`skipForDiscardable` which no longer contains
`nkIfStmt`/`nkCaseStmt`/`nkTryStmt`, stores the first encountered
returning node in a var parameter for the error message, and handles
`finally` and `nkIfExpr`.

Fixing #23677 already broke a line in `syncio` so some package code
might be affected.
2024-06-05 20:53:05 +02:00
..
2023-12-15 10:20:57 +01:00
2023-12-17 18:43:52 +01:00
2022-09-27 10:57:47 +02:00
2023-12-15 10:20:57 +01:00
2024-03-16 08:35:18 +08:00
2024-03-16 08:35:18 +08:00
2017-01-07 22:35:09 +01:00
2024-04-22 13:04:30 +02:00
2023-12-17 18:43:52 +01:00
2023-12-13 10:29:58 +01:00
2023-11-04 17:46:59 +08:00
2021-01-12 09:36:51 +01:00
2022-03-23 20:34:53 +01:00
2023-12-17 18:43:52 +01:00
2024-05-10 10:35:23 +02:00
2023-07-02 22:36:05 +02:00
2023-11-06 18:33:28 +01:00
2024-03-16 08:35:18 +08:00
2023-12-15 10:20:57 +01:00
2023-12-17 18:43:52 +01:00
2023-12-25 07:12:54 +01:00

Nim Compiler

  • This directory contains the Nim compiler written in Nim.
  • Note that this code has been translated from a bootstrapping version written in Pascal.
  • So the code is not a poster child of good Nim code.

See Internals of the Nim Compiler for more information.