From f7c11a8978a1fc7182ef18c4bdc80e920ce6ad88 Mon Sep 17 00:00:00 2001 From: metagn Date: Sun, 18 Aug 2024 01:52:32 +0300 Subject: allow generic compileTime proc folding (#22022) fixes #10753, fixes #22021, refs #19365 (was fixed by #22029, but more faithful test added) For whatever reason `compileTime` proc calls did not fold if the proc was generic ([since this folding was introduced](https://github.com/nim-lang/Nim/commit/c25ffbf2622a197c15a4a3bd790b1bc788db2c7f#diff-539da3a63df08fa987f1b0c67d26cdc690753843d110b6bf0805a685eeaffd40)). I'm guessing the intention was for *unresolved* generic procs to not fold, which is now the logic. Non-magic `compileTime` procs also now don't fold at compile time in `typeof` contexts to avoid possible runtime errors (only the important) and prevent double/needless evaluation. --- compiler/semdata.nim | 1 + 1 file changed, 1 insertion(+) (limited to 'compiler/semdata.nim') diff --git a/compiler/semdata.nim b/compiler/semdata.nim index 12930feca..6065e9845 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -168,6 +168,7 @@ type inUncheckedAssignSection*: int importModuleLookup*: Table[int, seq[int]] # (module.ident.id, [module.id]) skipTypes*: seq[PNode] # used to skip types between passes in type section. So far only used for inheritance, sets and generic bodies. + inTypeofContext*: int TBorrowState* = enum bsNone, bsReturnNotMatch, bsNoDistinct, bsGeneric, bsNotSupported, bsMatch -- cgit 1.4.1-2-gfad0