Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping for Miden SDK Rust bindings generation based on function names can accidentally skip user's functions #341

Open
greenhat opened this issue Oct 11, 2024 · 0 comments
Assignees
Milestone

Comments

@greenhat
Copy link
Contributor

greenhat commented Oct 11, 2024

Introduced in #329

Motivation

Using the function names to skip the Rust bindings generation for the Miden SDK and intrinsics functions at
https://github.com/0xPolygonMiden/compiler/blob/next/tools/cargo-miden/src/lib.rs

// skip functions that are provided by the Miden SDK and/or intrinsics
// only function names (no CM path)
package.metadata.section.bindings.skip = vec![
// Our function names can clash with user's function names leading to
// skipping the bindings generation of the user's function names
// see https://github.com/0xPolygonMiden/compiler/issues/341
    "remove-asset",
    "create-note",
    "heap-base",
    "hash-one-to-one",
    "hash-two-to-one",
    "add-asset",
    "add",
]

can accidentally skip bindings generation for user's functions if they have the same name as the intrinsics or Miden SDK functions (add, add-asset, create-note, etc.).

How to fix

We could add interface name support in the skip field in wit-bindgen. So that the whole Rust module (interface counterpart) is not generated. We would need to be careful and not break any wit-bindgen user's code, e.g. the function name skipping should continue to work as it is now. Ideally, we would want to specify the full path to the interface in the skip field, but if we're limited to using only the interface name we need to prioritize the function name skipping if both the interface and the function names are the same.
In this case, we have to make our interface names that we use in the skip field unique enough to not clash with the user's interface names.

@greenhat greenhat added this to the Beta 1 milestone Oct 11, 2024
@greenhat greenhat self-assigned this Oct 11, 2024
@greenhat greenhat changed the title Skipping for Miden SDK Rust bindings generation based on function names can accidentally skip user's functionsf Skipping for Miden SDK Rust bindings generation based on function names can accidentally skip user's functions Oct 11, 2024
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

No branches or pull requests

1 participant