Skip to content

Commit

Permalink
Mod -- has checking -- for top level Compose
Browse files Browse the repository at this point in the history
- begin-type.error.i
- begin-type-nested.error.i
  • Loading branch information
xieyuheng committed Aug 17, 2023
1 parent e67b6aa commit 48ab941
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 26 deletions.
5 changes: 0 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
top level env has checking -- for top level `Compose`

- begin-type.error.i
- begin-type-nested.error.i

# books

反应网编程
Expand Down
2 changes: 2 additions & 0 deletions src/lang/mod/Mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Loader } from "../../loader"
import { Checking } from "../checking"
import { Definition } from "../definition"
import { Env } from "../env/Env.js"
import { Rule } from "../rule"
Expand All @@ -7,6 +8,7 @@ import { Stmt } from "../stmt/Stmt.js"
export type Mod = {
loader: Loader
env: Env
checking: Checking
url: URL
text: string
stmts: Array<Stmt>
Expand Down
2 changes: 2 additions & 0 deletions src/lang/mod/createMod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Loader } from "../../loader"
import { defineBuiltinOperators } from "../builtins/defineBuiltinOperators"
import { createChecking } from "../checking/createChecking"
import { createEnv } from "../env/createEnv.js"
import { Stmt } from "../stmt/Stmt.js"
import { Mod } from "./Mod"
Expand All @@ -21,6 +22,7 @@ export function createMod(options: {
} as Mod

mod.env = createEnv(mod)
mod.checking = createChecking()

defineBuiltinOperators(mod)

Expand Down
4 changes: 3 additions & 1 deletion src/lang/stmts/Compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export class Compose implements Stmt {

async execute(mod: Mod): Promise<void> {
try {
compose(mod, mod.env, this.word, {})
compose(mod, mod.env, this.word, {
checking: mod.checking,
})
} catch (error) {
throw appendReport(error, {
message: [
Expand Down
2 changes: 0 additions & 2 deletions tests/checking/begin-type-nested.error.i
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ node cons
end

sole sole cons

TODO
15 changes: 7 additions & 8 deletions tests/checking/begin-type-nested.error.i.err
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
[lookupDefinitionOrFail] I meet undefined name.
[unifyTypes] I fail to unify types.

name: TODO
left: Trivial
right: Trivial List

[compose] I fail compose word.

word: TODO
word: cons

15 | 'A List :value!
16 |end
17 |
18 |sole sole cons
19 |
20 |TODO
21 |

[Compose.execute] I fail to compose word.

word: TODO
word: cons

15 | 'A List :value!
16 |end
17 |
18 |sole sole cons
19 |
20 |TODO
21 |
2 changes: 0 additions & 2 deletions tests/checking/begin-type.error.i
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ type Trivial -- Type end
node sole -- Trivial :value! end

sole add1

TODO
15 changes: 7 additions & 8 deletions tests/checking/begin-type.error.i.err
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
[lookupDefinitionOrFail] I meet undefined name.
[unifyTypes] I fail to unify types.

name: TODO
left: Trivial
right: Nat

[compose] I fail compose word.

word: TODO
word: add1

5 |type Trivial -- Type end
6 |node sole -- Trivial :value! end
7 |
8 |sole add1
9 |
10 |TODO
11 |

[Compose.execute] I fail to compose word.

word: TODO
word: add1

5 |type Trivial -- Type end
6 |node sole -- Trivial :value! end
7 |
8 |sole add1
9 |
10 |TODO
11 |

0 comments on commit 48ab941

Please sign in to comment.