Skip to content

Conversation

@DavePearce
Copy link
Collaborator

@DavePearce DavePearce commented Nov 17, 2025

Note

Add function call (defcall) support end-to-end with sample zkASM funcs and comprehensive unit/invalid tests.

  • Language/Compiler:
    • Add function call support (defcall) across corset (AST, parser, resolver, typing, translator, intrinsics, preprocessor) and IR (HIR, lowering, term/constraint handling).
  • ASM/zkASM:
    • Introduce sample functions (id, add u32, dec u16) with modulo arithmetic and preconditions.
  • Tests:
    • Add unit tests (fncall_01..03) with accepted/expanded outputs and edge cases.
    • Add invalid corset function call cases and update mixed large fixture.

Written by Cursor Bugbot for commit f644066. This will update automatically on new commits. Configure here.

This adds support for parsing defcall declarations, along with an
appropriate AST node.
This adds support for the resolution, processing and typing stages for
the DefCall construct.  An initial implementation of translation is also
included, but this does not yet actually translate the call.
This adds support for checking arguments and returns.  In particular,
check that there are enough arguments and returns, and also that their
bitwidths follow the expected subtyping pattern.
This adds support for encoding and decoding of function calls, and also
adds a number of tests.
@DavePearce DavePearce linked an issue Nov 17, 2025 that may be closed by this pull request
fmt.Sprintf("insufficient arguments for function \"%s\"", decl.Function)))
} else if i >= nArgs && !ith.IsOutput() {
return append(errors, *t.srcmap.SyntaxError(decl.Returns[i-nArgs],
fmt.Sprintf("too many arguments for function \"%s\"", decl.Function)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Error Message Confuses Returns with Arguments

The error message in checkArgsReturns is incorrect when checking returns. At line 355, when a return register is not marked as output (i >= nArgs && !ith.IsOutput()), the error message says "too many arguments" but should indicate a problem with returns or output registers. The message does not match the actual condition being validated.

Fix in Cursor Fix in Web

@DavePearce DavePearce merged commit e487520 into main Nov 17, 2025
22 checks passed
@DavePearce DavePearce deleted the 1322-feat-function-call-declaration branch November 17, 2025 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: function call declaration

2 participants