Skip to content

Add minimal user-defined functions implementation#413

Merged
rkalis merged 4 commits into
nextfrom
feat/functions-minimal
Jun 26, 2026
Merged

Add minimal user-defined functions implementation#413
rkalis merged 4 commits into
nextfrom
feat/functions-minimal

Conversation

@rkalis

@rkalis rkalis commented Jun 26, 2026

Copy link
Copy Markdown
Member
  • Add top-level user-defined function syntax
    • Functions can return a single value or nothing
  • Add import syntax
  • Imports are resolved and flattened into a single AST before compiler traversals
  • Used functions are defined at the top of a contract, their function
    bodies are compiled with a separate GenerateTargetTraversal + optimisations
  • Update builtin function compilation to self-document their bytecode
  • Update docs & release notes

This version does NOT YET support:

  • Multiple return values / tuples
  • Proper SDK debugging integration
  • Nested / multiple returns in a function
  • Advanced optimisations
  • Global constants
  • Cross-file pragma resolutions

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cashscript Ready Ready Preview, Comment Jun 26, 2026 2:05pm

Request Review

@rkalis rkalis changed the base branch from master to next June 26, 2026 11:01
Co-authored-by: lightswarm124 <lightswarm@gmail.com>
Co-authored-by: Mathieu Geukens <mr-zwets@protonmail.com>

- Add top-level user-defined function syntax
  - Functions can return a single value or nothing
- Add import syntax
- Imports are resolved and flattened into a single AST before compiler traversals
- Used functions are defined at the top of a contract, their function
  bodies are compiled with a separate GenerateTargetTraversal + optimisations
- Update builtin function compilation to self-document their bytecode
- Update docs & release notes

This version does NOT YET support:

- Multiple return values / tuples
- Proper SDK debugging integration
- Safety checks
- Nested / multiple returns in a function
- Advanced optimisations
- Global constants
- Cross-file pragma resolutions
@rkalis rkalis force-pushed the feat/functions-minimal branch from 19422ea to 6ab12fb Compare June 26, 2026 11:08
@rkalis rkalis marked this pull request as ready for review June 26, 2026 11:08
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.04520% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.31%. Comparing base (53f286b) to head (7edbfc4).

Files with missing lines Patch % Lines
packages/cashc/src/Errors.ts 85.00% 3 Missing ⚠️
...kages/cashc/src/print/OutputSourceCodeTraversal.ts 82.35% 3 Missing ⚠️
packages/cashc/src/ast/AST.ts 91.30% 2 Missing ⚠️
.../cashc/src/semantic/EnsureFinalRequireTraversal.ts 92.85% 2 Missing ⚠️
packages/cashc/src/ast/AstBuilder.ts 97.14% 1 Missing ⚠️
packages/cashc/src/ast/AstTraversal.ts 90.00% 1 Missing ⚠️
...es/cashc/src/generation/GenerateTargetTraversal.ts 96.87% 1 Missing ⚠️
packages/utils/src/types.ts 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next     #413      +/-   ##
==========================================
+ Coverage   85.69%   86.31%   +0.61%     
==========================================
  Files          51       55       +4     
  Lines        4041     4318     +277     
  Branches      757      805      +48     
==========================================
+ Hits         3463     3727     +264     
- Misses        453      465      +12     
- Partials      125      126       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rkalis rkalis merged commit 009e11c into next Jun 26, 2026
5 checks passed
@rkalis rkalis deleted the feat/functions-minimal branch June 26, 2026 14:08
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.

1 participant