Skip to content

Commit 60f9b97

Browse files
Apply suggestions from code review
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
1 parent c06c051 commit 60f9b97

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

spec/expr.typ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
assert(type(typ.at(1)) == int, message: "Array types need to have a constant dimension")
1010
typ = typ.at(0)
1111
}
12-
assert(type(typ.at(0)) == str, message: "Array types need to have a regular type as base")
12+
assert(type(typ) == str, message: "Array types need to have a regular type as base")
1313
}
1414

1515
// Render a type to code
@@ -60,7 +60,7 @@
6060
"cast": 3, // cast
6161
"mul": 4, // *
6262
"div": 5, // /
63-
"mod": 6, // %
63+
"mod": 6, // mod
6464
"sum": 7, // Σ
6565
"not": 8, // not
6666
"sub": 9, // -

spec/keccak.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The chip therefore contributes the following interaction to the lookup-argument:
3939

4040
The address containing the state to be permuted is passed in as argument `A0 = x10`.
4141
The following constraints describe that this address is read into `addr` (@keccak:c:read_addr), from which `state_ptr` --- the collection of pointers to all lanes of the state --- is derived (@keccak:c:state_ptr).
42-
The state is then read into `input_state`, while the `output_state` is written back to the indicated address (@keccack:c:load_store_state).
42+
The state is then read into `input_state`, while the `output_state` is written back to the indicated address (@keccak:c:load_store_state).
4343
#render_constraint_table(chip, config, groups: "mem")
4444

4545
Lastly, the input state is pushed to the Keccak-round function, while the output after 24 rounds is taken off the bus:

spec/tooling/chip.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,15 @@ def typecheck(self, env: Environment) -> Type:
264264
elt = self.elt.typecheck(env)
265265
modulus = self.modulus.typecheck(env)
266266

267+
if isinstance(modulus, list) or not modulus.is_const():
267268
if isinstance(modulus, list) or not modulus.is_const():
268269
reporter.error(f"Invalid non-constant modulus: {self.modulus!r}")
270+
return Range(0, 0) # sentinel; error already recorded
269271
modulus = modulus.get_const()
270272
if modulus <= 0:
271-
reporter.error(f"Invalid zero non-positive modulus: {self.modulus!r}")
273+
if modulus <= 0:
274+
reporter.error(f"Invalid non-positive modulus: {self.modulus!r}")
275+
return Range(0, 0) # sentinel; error already recorded
272276

273277
if elt.is_const():
274278
elt = elt.get_const()

0 commit comments

Comments
 (0)