Phase 8.2.4: Lifetime syntax ('a) support

- Lexer tokenizes 'a as tkLifetime
- Parser accepts lifetimes in type params <'a> and reference types &'a T / &'a mut T
- AST TypeExpr has refLifetime field for tekRef/tekMutRef
- TypeParam gains isLifetime flag for generic monomorphization
- Sema infers lifetime params as no-op dummy values; unwraps pointee types for params inside refs
- HIR lower skips lifetime params when generating mangled names and substitution tables
- &mut expr syntax supported in parser (consumed as part of unary &)
This commit is contained in:
2026-06-01 11:32:40 +03:00
parent 5830548d54
commit bf9e73d56e
6 changed files with 114 additions and 29 deletions
+2
View File
@@ -47,6 +47,7 @@ type
sliceSize*: Expr ## nil for unsized slices T[]
of tekOwn, tekPointer, tekRef, tekMutRef:
pointerPointee*: TypeExpr
refLifetime*: string ## only meaningful for tekRef/tekMutRef
of tekDynRef:
dynInterface*: string
of tekTuple:
@@ -300,6 +301,7 @@ type
TypeParam* = object
name*: string
bounds*: seq[string] ## e.g. ["Comparable"] for <T: Comparable>
isLifetime*: bool ## true for lifetime params like 'a
# ---------------------------------------------------------------------------
# Declarations