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

Future bug: Analyze function index offset for imported functions #27

Open
george-cosma opened this issue Jul 10, 2024 · 2 comments
Open

Comments

@george-cosma
Copy link
Collaborator

george-cosma commented Jul 10, 2024

According to the specs, imported functions are the first to be assigned an index and only afterwards do the normal functions get assigned indexes.

This issue was discovered when implementing a fix for issue #25 and is created in order to track progress on this potential future bug.

@valexandru valexandru changed the title Future bug: Analyze function index offset for imported function Future bug: Analyze function index offset for imported functions Jul 10, 2024
@george-cosma
Copy link
Collaborator Author

george-cosma commented Jul 10, 2024

Just a small observation: this does not seem to be an issue for now. In the same_type_fn implemented in pr #26, if I add an import to the wat, all tests pass.

(module
    (import "test" "testFunc" (func (param i64 i64) (result i64)))
    (func (export "add_one") (param $x i32) (result i32)
        local.get $x
        i32.const 1
        i32.add)

    (func (export "add_two") (param $x i32) (result i32)
        local.get $x
        i32.const 2
        i32.add)
)

Although the imported function seems to get the ID of 0 (for type), the functions section only deals with the functions declared in the module. As such, both functions get parsed as type of ID 1, correctly.

This does not mean the issue is fixed. We still need to be careful when actually implementing imported functions.

@george-cosma
Copy link
Collaborator Author

Relevant also to #87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants