feat: add borrow test example, fix borrow &mut parsing order
- examples/borrow.bux: working borrow expression example - tests/borrow_test.nim: add 4 new tests for borrow & @[Shared] - parser.nim: fix borrow parsing order (& before mut) - Build verified: example compiles and runs
This commit is contained in:
@@ -1200,6 +1200,15 @@ proc checkExpr(sema: var Sema, expr: Expr, scope: Scope): Type =
|
||||
let operand = sema.checkExpr(expr.exprAwaitOperand, scope)
|
||||
# await on a task handle returns *void (result pointer)
|
||||
return makePointer(makeVoid())
|
||||
of ekBorrow:
|
||||
let operand = sema.checkExpr(expr.exprBorrowOperand, scope)
|
||||
# borrow &mut expr returns the same type as the original (reference)
|
||||
# The borrow is tracked in the borrow checker
|
||||
if sema.checkedFunc and expr.exprBorrowMutable:
|
||||
# Track: variable "operand" is mutably borrowed here
|
||||
# For now, just validate the type
|
||||
discard
|
||||
return operand
|
||||
of ekSpread:
|
||||
return sema.checkExpr(expr.exprSpreadOperand, scope)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user