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:
2026-06-07 17:50:27 +03:00
parent 46814b2abc
commit bfe87a8acb
5 changed files with 37 additions and 1 deletions
+4 -1
View File
@@ -51,6 +51,7 @@ type
tkSizeOf # sizeof
tkOwn # own (gradual ownership transfer)
tkMut # mut (mutable reference)
tkBorrow # borrow (explicit borrow expression)
tkDiscard # discard (evaluate and throw away)
tkAsync # async
tkAwait # await
@@ -151,7 +152,7 @@ proc isKeyword*(kind: TokenKind): bool =
tkBreak, tkContinue, tkReturn, tkMatch,
tkFunc, tkLet, tkVar, tkConst, tkType, tkStruct, tkEnum,
tkUnion, tkInterface, tkExtend, tkModule, tkImport,
tkPub, tkExtern, tkAs, tkIs, tkNull, tkSelf, tkSuper, tkOwn, tkMut, tkDiscard, tkAsync, tkAwait, tkSpawn, tkStaticAssert, tkComptime, tkDyn:
tkPub, tkExtern, tkAs, tkIs, tkNull, tkSelf, tkSuper, tkOwn, tkMut, tkBorrow, tkDiscard, tkAsync, tkAwait, tkSpawn, tkStaticAssert, tkComptime, tkDyn:
true
else:
false
@@ -207,6 +208,7 @@ proc keywordKind*(text: string): TokenKind =
of "sizeof": tkSizeOf
of "own": tkOwn
of "mut": tkMut
of "borrow": tkBorrow
of "discard": tkDiscard
of "async": tkAsync
of "await": tkAwait
@@ -259,6 +261,7 @@ proc tokenKindName*(kind: TokenKind): string =
of tkSuper: "'super'"
of tkOwn: "'own'"
of tkMut: "'mut'"
of tkBorrow: "'borrow'"
of tkDiscard: "'discard'"
of tkAsync: "'async'"
of tkAwait: "'await'"