-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[move-compiler-v2] clean up a few remaining issues in lambda parser/front-end code #15365
base: 09-27-add_parser_code_for_lambda_types
Are you sure you want to change the base?
[move-compiler-v2] clean up a few remaining issues in lambda parser/front-end code #15365
Conversation
⏱️ 1h 20m total CI duration on this PR
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
3e3563e
to
dac085c
Compare
env.error( | ||
&loc, | ||
// TODO(LAMBDA) | ||
"Lambdas expressions with `store` ability currently may only be a simple call to an existing `public` function. This lambda expression requires defining a `public` helper function, which might affect module upgradeability and is not yet supported." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error message looks a little bit confusing for users (e.g what is a helper
function and how it may affect upgradeability). Maybe just remove
requires defining a public
helper function, which might affect module upgradeability` and just saying it is not supported yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
env.error( | ||
&loc, | ||
&format!( | ||
"captured variable `{}` must have a value with `copy` ability", // TODO(LAMBDA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test case for this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added closure_args.move
, see closure_args.lambda.exp
.
This exercises a lot of cases.
9395a8f
to
cead217
Compare
dac085c
to
42421fe
Compare
self.emit_call(id, vec![target], BytecodeOperation::ReadRef, vec![ | ||
borrow_dest, | ||
]) | ||
self.emit_call( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like formatting only change? When I run the formatter, it goes back to the original.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
probing_vars: Some(_), | ||
.. | ||
}) | ||
matches!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar as above, when I run the formatter, this goes back to original.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be fixed,
} | ||
|
||
public inline fun quux(f:|u64, u64|u64, a: u64, b: u64): u64 { | ||
f(a, b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add test cases where we have:
- Use statement importing (at the module level and at the function level) a function
foo
, wherefoo
is also a function parameter to an inline function like here. - Similar as above, but without explicit use statement and instead explicit qualification like
other_module::foo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rather tangential to this PR, but I've added use statements. The explicit qualification case is not interesting, as we know what it will do.
What is happening is very clear if you look at move-compiler/src/expander/translation.rs
and .../aliases.rs
, which tracks nesting of use
of symbols from other modules. All that is tracked are those imported symbols, not any local variables. A name in function call position (and a few other places) is turned into an explicit ModuleIdent::Name
pair. A name in other positions may be left unevaluated until later.
node_id, | ||
modified: true, | ||
}); | ||
self.free_locals.insert( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A number of changes here seem to be only whitespace changes that go away when I format. Any idea how these changes came by?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge conflicts? Also, Emacs sometimes indents differently than the Rust usual.
let Some((mut params, mut closure_args, param_index_mapping)) = | ||
self.get_params_for_freevars() | ||
else { | ||
return None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the ?
operator fits well here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, though I personally find it a little too subtle.
cead217
to
44baaf0
Compare
42421fe
to
92ae56c
Compare
92ae56c
to
3c02ba1
Compare
Description
Various fixes:
Constraint::NoFunction
as it's too broad._ok
versions that compile up to "not implemented" errors.How Has This Been Tested?
Usual tests run, showing unchanged behavior on existing code. Tests under
/lambda/
without.lambda.
config show proper errors generated if to many functions are used._ok
tests now show code working up until "not implemented" errors.Key Areas to Review
Most complex stuff is in previous PR, but:
store
andcopy
properties in captured free variables?/lambda/storage/*_ok.move
tests look like reasonable code to expect from users?Type of Change
Which Components or Systems Does This Change Impact?
Checklist