fix(stdlib): accept null return_type for void Noir functions#21647
Merged
Thunkar merged 1 commit intomerge-train/fairiesfrom Mar 17, 2026
Merged
fix(stdlib): accept null return_type for void Noir functions#21647Thunkar merged 1 commit intomerge-train/fairiesfrom
Thunkar merged 1 commit intomerge-train/fairiesfrom
Conversation
cc08554 to
478515c
Compare
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
cc08554 to
478515c
Compare
…tions The Noir compiler outputs `"return_type": null` for void functions, but our NoirFunctionAbi type only accepted a non-null object. This caused a TypeScript error when using `aztec-builder codegen` on contracts whose only functions are the macro-injected void lifecycle functions (e.g. a blank `#[aztec] contract`). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a8098fc to
477572e
Compare
Thunkar
approved these changes
Mar 17, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 18, 2026
BEGIN_COMMIT_OVERRIDE fix(stdlib): accept null return_type for void Noir functions (#21647) feat!: make AES128 decrypt oracle return Option (#21696) fix(aztec-nr): fix OOB index with nonzero offset (#21613) feat!: include init_hash in private initialization nullifier to prevent privacy leak (#21427) END_COMMIT_OVERRIDE
AztecBot
pushed a commit
that referenced
this pull request
Mar 18, 2026
Fixing issue reproted by @just-mitch on [slack](https://aztecprotocol.slack.com/archives/C04PUD9AA4W/p1773715408859609). ## AI Summary Fixes a TypeScript compilation error when running `aztec-builder codegen` on contracts where every function is void (most notably, a blank `#[aztec] contract Main {}`). The `#[aztec]` macro injects lifecycle functions like `process_message` and `sync_state` into every contract. These are void, so the Noir compiler outputs `"return_type": null` for them. Our `NoirFunctionAbi` type only accepted a non-null object for `return_type`, which caused a type error on the `as NoirCompiledContract` cast in the generated TS. For contracts with at least one non-void function, TypeScript infers the JSON array element type as a union (`null | { abi_type, visibility }`), which has enough overlap with the expected type for the `as` cast to succeed. But when *every* function is void, the inferred type is just `null` — zero overlap — so the cast fails. The runtime code in `contract_artifact.ts` already handled the `null` case correctly. Only the type definition was out of sync with the compiler's actual output. Repro: https://github.com/just-mitch/mytoken ## Test plan - Verified `yarn build` passes with no new type errors - Cloned the repro, confirmed the TS error, patched `node_modules/@aztec/stdlib` with the fix, confirmed clean compilation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
✅ Successfully backported to backport-to-v4-next-staging #21654. |
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.

Fixing issue reproted by @just-mitch on slack.
AI Summary
Fixes a TypeScript compilation error when running
aztec-builder codegenon contracts where every function is void (most notably, a blank#[aztec] contract Main {}).The
#[aztec]macro injects lifecycle functions likeprocess_messageandsync_stateinto every contract. These are void, so the Noir compiler outputs"return_type": nullfor them. OurNoirFunctionAbitype only accepted a non-null object forreturn_type, which caused a type error on theas NoirCompiledContractcast in the generated TS.For contracts with at least one non-void function, TypeScript infers the JSON array element type as a union (
null | { abi_type, visibility }), which has enough overlap with the expected type for theascast to succeed. But when every function is void, the inferred type is justnull— zero overlap — so the cast fails.The runtime code in
contract_artifact.tsalready handled thenullcase correctly. Only the type definition was out of sync with the compiler's actual output.Repro: https://github.com/just-mitch/mytoken
Test plan
yarn buildpasses with no new type errorsnode_modules/@aztec/stdlibwith the fix, confirmed clean compilation🤖 Generated with Claude Code