Skip to content

Commit

Permalink
[lang0] execute -- should not return void -- to catch sum type
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Mar 31, 2024
1 parent e1a0981 commit 6653354
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[lang0] `execute` -- should not return void -- to catch sum type

[lang1] 支持 `(import)`
[lang1] 支持 `(assert-equal)``(assert-not-equal)`
[lang1] 直接用 lang0 的测试
Expand Down
10 changes: 6 additions & 4 deletions src/lang0/run/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import { readback, ReadbackCtx } from "../readback/index.js"
import type { Define, Stmt } from "../stmt/Stmt.js"
import { executeMod } from "./executeMod.js"

export function execute(mod: Mod, stmt: Stmt): void | string {
export function execute(mod: Mod, stmt: Stmt): null | string {
switch (stmt["@kind"]) {
case "AssertEqual": {
for (let i = 0; i < stmt.exps.length - 1; i++) {
assertEqual(mod, stmt.exps[i], stmt.exps[i + 1])
}

return
return null
}

case "AssertNotEqual": {
for (let i = 0; i < stmt.exps.length - 1; i++) {
assertNotEqual(mod, stmt.exps[i], stmt.exps[i + 1])
}

return
return null
}

case "Compute": {
Expand All @@ -43,7 +43,7 @@ export function execute(mod: Mod, stmt: Stmt): void | string {
exp: stmt.exp,
})

return
return null
}

case "Import": {
Expand All @@ -69,6 +69,8 @@ export function execute(mod: Mod, stmt: Stmt): void | string {

modDefine(mod, rename || name, def)
}

return null
}
}
}
Expand Down

0 comments on commit 6653354

Please sign in to comment.