This commit is contained in:
ringabout
2026-05-06 22:48:37 +08:00
parent 5059bb40e5
commit f4cd77c318
2 changed files with 11 additions and 1 deletions

View File

@@ -459,9 +459,10 @@ proc normalizeTypedescMacroResult(c: PContext, n: PNode): PNode =
if result.kind == nkStmtList:
result.transitionSonsKind(nkStmtListType)
const maxTypedescMacroNormalizationPasses = 32
# Resolve surviving compile-time branches so later passes don't walk
# unevaluated type AST for a typedesc expression.
while true:
for _ in 0..<maxTypedescMacroNormalizationPasses:
if result.kind == nkWhenStmt:
result = semWhen(c, result, false)
if result.kind == nkStmtList:

View File

@@ -45,3 +45,12 @@ elif compiles(nonexistent):
else:
output("whenElse")
template test(): typedesc =
when true:
int
else:
bool
const c = default(test())
echo c