Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check returns in untyped host functions #27

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

Merged

Conversation

WhaleKit
Copy link
Contributor

@WhaleKit WhaleKit commented Dec 28, 2024

Host function created with Extern::func could return wrong types and executor wouldn't notice. So I took a crack at fixing it. I'm a rust beginner though, so review carefully

I'm not sure about tests location - so far I've put them into "test" folder in the repo root which (if I understood "integration tests" chapter) is a standard way to test public api. Test suite doesn't have "wat" module and appears to me to be directed more at wasm side, rather than host side api.

I also added checks to that test file to ensure that host function don't link if types mismatch, because i could i had utility functions for trying combinations anyway, and they are thematically close (as "imported host function signature")

@WhaleKit WhaleKit marked this pull request as ready for review December 28, 2024 17:05
@WhaleKit WhaleKit changed the title Check untyped returns Check returns in untyped host functions Dec 30, 2024
- Move test to crate directory
- Remove types argument from HostFuncs
- Update CHANGELOG.md

Signed-off-by: Henry Gressmann <[email protected]>
Copy link
Owner

@explodingcamera explodingcamera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I've removed the return types arg for now, if there's a use-case to have it I'd probably rather add it to the ctx. I've moved the tests to the tinywasm crate for now, but I might reorganize them a bit later.

@explodingcamera explodingcamera merged commit 0202878 into explodingcamera:next Jan 6, 2025
8 checks passed
@WhaleKit
Copy link
Contributor Author

WhaleKit commented Jan 6, 2025

I see. I did that, because it didn't make host function carry its expected types, which are already known at the time and place of calling - but admittedly it is more awkward to pass them every time

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