Stream: git-wasmtime

Topic: wasmtime / issue #7784 bindgen: Generates names which may...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 17 2024 at 19:08):

jcbhmr added the bug label to Issue #7784.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 17 2024 at 19:08):

jcbhmr opened issue #7784:

Thanks for filing a bug report! Please fill out the TODOs below.

Note: if you want to report a security issue, please read our security policy!

Test Case

TODO: upload Wasm file here

Steps to Reproduce

package typst-community:unicode-math-class;

/// ROOT [Crate unicode_math_class](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/)
interface crate {
    // [Enum unicode_math_class::MathClass](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/enum.MathClass.html)
    enum math-class {
        normal,
        alphabetic,
        binary,
        closing,
        diacritic,
        fence,
        glyph-part,
        large,
        opening,
        punctuation,
        relation,
        space,
        unary,
        vary,
        special,
    }

    /// [Constant unicode_math_class::REVISION](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/constant.REVISION.html)
    revision: func() -> u8;

    /// [Function unicode_math_class::class](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/fn.class.html)
    class: func(c: string) -> option<math-class>;
}

/// [Crate unicode_math_class](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/)
world unicode-math-class {
    export crate;
}

Expected Results

TODO: What do you expect to happen?

Similar to wit-bindgen, I expected the "crate" to become "crate_"

cargo_component_bindings::generate!();
use bindings::exports::typst_community::unicode_math_class::crate_ as wit;
use unicode_math_class as rs;

mod math_class;

pub struct Component;

impl wit::Guest for Component {
    fn revision() -> u8 {
        rs::REVISION
    }
    fn class(c: String) -> Option<wit::MathClass> {
        let c = c.chars().next().unwrap();
        rs::class(c).map(|x| x.into())
    }
}

Actual Results

TODO: What actually happens? Panic? Segfault? Incorrect result?

jcbhmr@PIG-2016:~/Documents/unicode-math-class.wasm$ make test-rs
cargo test -p tests-rs
   Compiling tests-rs v0.0.0 (/home/jcbhmr/Documents/unicode-math-class.wasm/tests/rs)
error: expected identifier, found keyword `crate`
 --> tests/rs/tests/common/mod.rs:6:5
  |
6 |     bindgen!(in "../../wit");
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
  |
  = note: this error originates in the macro `bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

Versions and Environment

Wasmtime version or commit: 16.0.0

Operating system: Windows 10 using WSL

Architecture: x86_64

Extra Info

Anything else you'd like to add?

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2024 at 00:32):

alexcrichton commented on issue #7784:

Thanks! This'd be a good first issue if anyone's willing to tackle it. We've already got a function for handling Rust keywords but we're probably forgetting to call it somewhere. This issue will involve hunting down where the forgotten location is, probably inserting a call to to_rust_ident, and then adding a test case in crates/component-macro/tests/codegen.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2024 at 00:32):

alexcrichton added the wasm-proposal:component-model label to Issue #7784.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2024 at 00:32):

alexcrichton added the good first issue label to Issue #7784.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2024 at 03:31):

Archisman-Mridha commented on issue #7784:

@alexcrichton You can assign this to me. I am working on it.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2024 at 03:53):

Archisman-Mridha edited a comment on issue #7784:

@alexcrichton You can assign this to me. I am working on it.

We need to to_rust_ident probably somewhere inside Wasmtime::name_interface in crates/wit-bindgen/src/lib.rs.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2024 at 03:54):

Archisman-Mridha edited a comment on issue #7784:

@alexcrichton You can assign this to me. I am working on it.

We need to use to_rust_ident probably somewhere inside Wasmtime::name_interface in crates/wit-bindgen/src/lib.rs.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 12 2024 at 19:27):

alexcrichton closed issue #7784:

Thanks for filing a bug report! Please fill out the TODOs below.

Note: if you want to report a security issue, please read our security policy!

Test Case

TODO: upload Wasm file here

Steps to Reproduce

package typst-community:unicode-math-class;

/// ROOT [Crate unicode_math_class](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/)
interface crate {
    // [Enum unicode_math_class::MathClass](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/enum.MathClass.html)
    enum math-class {
        normal,
        alphabetic,
        binary,
        closing,
        diacritic,
        fence,
        glyph-part,
        large,
        opening,
        punctuation,
        relation,
        space,
        unary,
        vary,
        special,
    }

    /// [Constant unicode_math_class::REVISION](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/constant.REVISION.html)
    revision: func() -> u8;

    /// [Function unicode_math_class::class](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/fn.class.html)
    class: func(c: string) -> option<math-class>;
}

/// [Crate unicode_math_class](https://docs.rs/unicode-math-class/0.1.0/unicode_math_class/)
world unicode-math-class {
    export crate;
}

Expected Results

TODO: What do you expect to happen?

Similar to wit-bindgen, I expected the "crate" to become "crate_"

cargo_component_bindings::generate!();
use bindings::exports::typst_community::unicode_math_class::crate_ as wit;
use unicode_math_class as rs;

mod math_class;

pub struct Component;

impl wit::Guest for Component {
    fn revision() -> u8 {
        rs::REVISION
    }
    fn class(c: String) -> Option<wit::MathClass> {
        let c = c.chars().next().unwrap();
        rs::class(c).map(|x| x.into())
    }
}

Actual Results

TODO: What actually happens? Panic? Segfault? Incorrect result?

jcbhmr@PIG-2016:~/Documents/unicode-math-class.wasm$ make test-rs
cargo test -p tests-rs
   Compiling tests-rs v0.0.0 (/home/jcbhmr/Documents/unicode-math-class.wasm/tests/rs)
error: expected identifier, found keyword `crate`
 --> tests/rs/tests/common/mod.rs:6:5
  |
6 |     bindgen!(in "../../wit");
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
  |
  = note: this error originates in the macro `bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

Versions and Environment

Wasmtime version or commit: 16.0.0

Operating system: Windows 10 using WSL

Architecture: x86_64

Extra Info

Anything else you'd like to add?


Last updated: Dec 23 2024 at 12:05 UTC