Skip to content

feat!: error on non-DSL pub fn in exportModule#38

Merged
nazarhussain merged 2 commits into
mainfrom
bing/warn-dsl
May 26, 2026
Merged

feat!: error on non-DSL pub fn in exportModule#38
nazarhussain merged 2 commits into
mainfrom
bing/warn-dsl

Conversation

@spiral-ladder
Copy link
Copy Markdown
Contributor

@spiral-ladder spiral-ladder commented May 22, 2026

js.exportModule previously silently dropped pub fns whose parameters weren't DSL-compatible. That made it easy to ship a function you thought was exported but wasn't (see ChainSafe/lodestar-z#371).

Now exportModule raises a @compileError naming the offending decl.
Fix it by one of:

  • use DSL-compatible parameters (e.g. js.Number),
  • drop pub if the function is a helper not meant for JS,
  • pass a custom .register to js.exportModule to export the function manually.

BREAKING CHANGE

Modules with non-DSL pub fns alongside DSL exports will no longer build.

Zig functions are skipped if they:

1) are not `pub fn`,
2) do not use DSL-compatible types from the `js` module

We can't error since we want flexibility to define and use other
functions in the same file, so we just
add a simple warning to warn the user about this at comptime.

This is to avoid future situations encountered here: ChainSafe/lodestar-z#371
@spiral-ladder spiral-ladder self-assigned this May 22, 2026
@nazarhussain nazarhussain changed the title feat: warn when dsl incompatible functions are skipped feat!: error on non-DSL pub fn in exportModule May 26, 2026
@nazarhussain
Copy link
Copy Markdown
Contributor

Problem with simple warning is that binding author might not notice it at all, as most of the time there will some CI workflow building buildings, not a human looking at build warnings. And then for binding consumer that warning will be too late to address any solution.

@nazarhussain nazarhussain merged commit d72deb7 into main May 26, 2026
9 of 15 checks passed
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.

2 participants