mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 08:54:25 +00:00
boot: defer, str.bytes()
defer runs when its scope ends and before return, break and continue leave it, newest first, and sees only the variables declared before it. Not allowed inside a defer: defer, return, break, continue. boot.sh: 14 passed, 0 failed, 8 skipped.
This commit is contained in:
parent
051af1a04e
commit
84693aa655
3 changed files with 96 additions and 9 deletions
|
|
@ -283,7 +283,16 @@ fn parseStatement(ptr[Parser] p) -> ast.Node {
|
|||
if k == "{" {
|
||||
return parseBlock(p)
|
||||
}
|
||||
if k == "fn" || k == "struct" || k == "import" || k == "defer" || k == "link" {
|
||||
if k == "defer" {
|
||||
s := node(p, "defer")
|
||||
next(p)
|
||||
if at(p, "defer") {
|
||||
fail(p, cur(p), "defer inside defer is not allowed")
|
||||
}
|
||||
s.kids.push(parseStatement(p))
|
||||
return s
|
||||
}
|
||||
if k == "fn" || k == "struct" || k == "import" || k == "link" {
|
||||
fail(p, cur(p), "'" + k + "' can't be used here in the self-hosted compiler")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue