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

Resolve string idents from scope #12

Merged
merged 1 commit into from Mar 7, 2024

Conversation

ThorstenHans
Copy link
Contributor

This allows users to pass strings to function calls using local variables

wepl mymodule.wasm
World: root:component/root
> .exports
reverse: func(input: string) -> string
> foo = "bar"
foo: string
> reverse(foo)
"oof"
>

Signed-off-by: Thorsten Hans <thorsten.hans@fermyon.com>
Copy link
Owner

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Let me know if you want to implement the improvement I suggested - otherwise I can merge this and submit another PR later.

@@ -240,7 +240,8 @@ impl<'a> Evaluator<'a> {
| component::Type::S8
| component::Type::S16
| component::Type::S32
| component::Type::S64 => self.lookup_in_scope(ident),
| component::Type::S64
| component::Type::String => self.lookup_in_scope(ident),
Copy link
Owner

Choose a reason for hiding this comment

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

I'm trying to remember why we wouldn't just always look up in scope if it's not one of the special types we'd like to handle... I wonder if we should instead get rid of this arm and turn it into:

_ => self.lookup_in_scope(ident)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to provide an additional PR to head into that direction. Unfortunately, I saw your comment after you merged the PR

@rylev rylev merged commit 95609f9 into rylev:main Mar 7, 2024
1 check 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.

None yet

2 participants