You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation bug: The BendRT paper’s opening example fails type checking #1308
The first program in the BendRT paper fails type checking with Bend 2.0.35 because its arithmetic expressions lack the required type annotations. Adding three U32 annotations makes the example check and run. Readers copying the published example otherwise encounter an error before they can run it.
What you did
I saved the first Bend block of bend2/docs/BendRT/main.typ (lines 150-174, the same program as page 1 of paper/BendRT.pdf) as example.bend and ran:
bun bend2/main.ts example.bend --check-only
What happened
Exit 1:
SOME PROOFS FAIL
Error:
- message : a type for this operator (write (a * b : Nat))
Location:
11 | case 1n+p:
12>| l r = build(p, i * 2) build(p, i * 2 + 1)
| ^
13 | Node{l, r}
Note: we broke this after launch, sorry. Until 2.0.16 a bare operator meant Nat.
That was a bug: operators demand annotation. Wrap the expression and it'll work again.
Commit 176842d3 makes an operator take its type from the ( .. : T) around its own expression. The paper's example still uses bare operators. Commit 573002f0, a later commit, rebuilt both papers without changing this example.
Expected behavior
The paper's first example checks and runs. For example, annotate the operators ((i * 2 : U32), (i * 2 + 1 : U32), (a + b : U32); with these three changes the file checks, runs and prints 4294443008), then rebuild paper/BendRT.pdf. A check that extracts this block and runs --check-only on it would catch the next drift.
bend --version
bun bend2/main.ts version prints bend 2.0.35 (bun 1.4.2), at commit 2bfc83fd6cc64cc08c6eaa225aacb69c86072788.
uname -sm
Darwin arm64
The file
import Base
type Tree is Type:
Leaf{x: U32}
Node{l: Tree, r: Tree}
def build(+d: Nat, +i: U32) -> Tree:
match d:
case 0n:
Leaf{i}
case 1n+p:
l r = build(p, i * 2) build(p, i * 2 + 1)
Node{l, r}
def sum(t: Tree) -> U32:
match t:
case Leaf{x}:
x
case Node{l, r}:
a b = sum(l) sum(r)
a + b
def main() -> IO(Unit):
t = build(20n, 0)
IO.print(U32.show(sum!(t)))
Activity