feat(release): add @[Release] attribute and --release CLI flag

- @[Release] disables borrow checking and bounds checking in the function
- --release passes -O3 -flto to the C compiler for optimized builds
- Selfhost loop still deterministic
This commit is contained in:
2026-06-11 09:39:11 +03:00
parent 224542df7f
commit 290cbc8f98
5 changed files with 66 additions and 24 deletions
+7 -1
View File
@@ -1571,9 +1571,10 @@ func parserParseDecl(p: *Parser) -> *Decl {
}
let isPublic: bool = parserMatch(p, tkPub);
// Parse @[Checked] / @[Drop] attribute
// Parse @[Checked] / @[Drop] / @[Release] attribute
var isChecked: int = 0;
var isDrop: int = 0;
var isRelease: int = 0;
if parserCheck(p, tkAt) {
discard parserAdvance(p); // @
if parserCheck(p, tkLBracket) {
@@ -1586,6 +1587,9 @@ func parserParseDecl(p: *Parser) -> *Decl {
if String_Eq(attrName.text, "Drop") {
isDrop = 1;
}
if String_Eq(attrName.text, "Release") {
isRelease = 1;
}
discard parserAdvance(p); // attribute name
}
if parserCheck(p, tkRBracket) {
@@ -1604,11 +1608,13 @@ func parserParseDecl(p: *Parser) -> *Decl {
discard parserAdvance(p); // async
let d: *Decl = parserParseFuncDecl(p, isPublic, false, true);
d.isChecked = isChecked;
d.isRelease = isRelease;
return d;
}
if kind == tkFunc {
let d: *Decl = parserParseFuncDecl(p, isPublic, false, false);
d.isChecked = isChecked;
d.isRelease = isRelease;
return d;
}
if kind == tkStruct {