Conversation
|
Thank you for your contribution to the Noir language. Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch. Thanks for your understanding. |
BornPsych
force-pushed
the
ys/goldilocks-stage-5d
branch
from
September 22, 2026 16:45
0396301 to
ba5582e
Compare
BornPsych
changed the base branch from
ys/goldilocks-stage-5b
to
provekit-v2
September 22, 2026 16:45
… without allocating
BornPsych
added this pull request to stack #21
September 22, 2026 23:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 5d of the Goldilocks port, stacked on #17. It changes the width rule that #16 introduced: an integer type may now have any width from 2 through 16384 bits, odd or even, for both signednesses, where before it was 8, 16 and the even widths from 32 to 65536. The cap is the one the Mavros compiler accepts (
MAX_SUPPORTED_INT_BITS = 1 << 14), so every width the frontend admits is one the consumer of the monomorphized output takes; which operations it can lower at a given width is its own question.u2,u3,u10,i24andu33are types like any other;u65536is refused. On bn254 nothing changes on the circuit path: the backend still lowersu8throughu128andi8throughi64and refuses every other width at the same place as before.Three things I'd point a reviewer at.
Width 1 is refused in every spelling and is never an alias of
bool.u1andi1already said "u1has been removed, useboolinstead"; nowu<1>,i<1>and a generic width that binds to 1 at monomorphization print that same sentence as the note under "u1is not a supported integer type", so a user reads one instruction whichever way they wrote it. An alias would have madeu<N>atN = 1the same type asbooland put everyimplonboolin coherence with theu<N>impls.u0andi0are now read as integer type names too (a lone0was not a width before), so they get the width diagnostic instead of an unresolved name. The same diagnostic is raised in an expression path,u16385::max_value(), where the name is looked up as a primitive type rather than resolved as a type and used to come back as "Could not resolve". Its three renderers, at resolution, in path resolution and at monomorphization, share one function.compile_no_checkrunsensure_field_is_linkedafter monomorphization instead of before it. Monomorphization is front-half work and runs under any field, so the hidden--show-monomorphizednow prints the program, and a monomorphization error is reported as such, when the requested field is not the one the compiler was built with. The guard still sits ahead of the cache read, so a cached artifact for the built field is never returned for another. Nothing changes when the field matches.The standard library gains no
#[test]for the small widths. Its test runner compiles every stdlib test to a circuit in two of its three lanes, and the backend cannot loweru2oru3, so theu2/i2/u3/i3limits are pinned in the driver'sstdlib_elaboration.rs, which evaluates them at compile time under every configured field. The genericmax_value/min_valueimpls needed no change:i<N>::max_valueshifts byN - 2, which is 0 atN = 2.Elsewhere: the lexer's coarse literal ceiling follows the constant and is now
2^16384 - 1; the widest width in the frontend's width tests moves from 65536 to 16384 and the widths 2, 3 and 33 join the literal-bound sweep;design/field-genericity.mdstates the new rule, cites the cap, records why width 1 is refused rather than aliased, and notes that the ECDSA foreigns carry no field at any plane whilekeccakf1600has no Mavros replacement under any field.Tests:
width_contract.rsgainsevery_spelling_of_width_1_says_use_bool_and_width_0_is_refused, which pins the rendered message and note foru1,u<1>,i<1>,u0and a generic bound to 1, anda_width_the_language_does_not_have_is_refused_in_an_expression_pathforu16385::max_value(),i0::max_value()andu1::max_value().field_selection.rsgainsmonomorphization_reports_before_the_linked_field_guard, red before the guard moved (the error wasUnsupportedField) and green after (MonomorphizationError). The driver's width boundary test addsu3, and the small-width limits sit next to theu34/i128ones instdlib_elaboration.rs.Gates on the tip: frontend 2301 and driver 33 tests, the stdlib runner's 9 matrix cells, the Goldilocks lane's test command 2384 tests, clippy at
-Dwarningsacross the workspace and rustfmt clean, andnargoby hand onu3(passescheck, stops at the backend),u<1>,i<1>,u0,u16385, the small-width limits under both fields, and--show-monomorphized --field goldilocks. Theexecutesnapshot suite was not rerun; no snapshot carries the rule text.Known follow-ups, not here: the monomorphizer reports a generic width bound past the rule at the call site rather than at the signature; the ast-interpreter companion regenerates its width fixtures at the new rule.