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

[move-compiler-v2] add parser code for lambda types #14792

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

brmataptos
Copy link
Contributor

@brmataptos brmataptos commented Sep 28, 2024

Description

Extend syntax

  • lambda expression: move |args| body with copy+store. Note that:
    • we don't use has copy, store because commas will confuse parsing in many situation
    • we don't use has copy+store because that leads to nonuniform syntax with has
    • at some point Wolfgang suggested with, so that's what we're using.
  • function types: |T1, T2| T3 with copy+store
  • curry construction:
    • from lambda: |a, b| f(x, 3, a, b)
    • to simplify review, EarlyBind expression now takes a function-valued expression and a set of argument expressions, which correspond to a prefix of the function parameters.
  • arbitrary function calls:
    • (|x, y| x + y)(2, 3)
  • suppress printing common abilities (all functions have drop)

Modify exp_builder and lambda_lifter to generate function values.

Modify model to track "used" functions in addition to "called" functions to be able to catch all dependencies when function values are created but not called.

Attaches an AbilitySet to Type::Fun and Exp::Lambda based on source. Adds a new ExpCall operation in parser/expansion ASTs to be able to carry more generalized function calls through to move-model, which already can support this through Invoke, which previously was underutilized. Added basic type checking for function abilities.

Current Gaps

I was targeting the test cases return_func.move and doable_func.move, but this PR is still missing

  • inference of ability store for function values built by curry with only storable parameters
  • allowing storable function types as type parameters and function returns

I will try to patch those in while this is being reviewed, or add them to a later PR.

How Has This Been Tested?

Added more lambda tests under move-compiler-v2/tests/lambda/ which are run "with" and "without" lambda features enabled. Currently, many things pass through to hit "not yet implemented" errors in bytecode gen, etc.

Ran and carefully checked all tests under third_party and aptos.

Key Areas to Review

Key features are illustrated in test move-compiler-v2/tests/lambda/storable/doable_func.move and the two corresponding output files, along with the test return_func.move in the same directory. Most other test outputs should be largely unchanged, although error messages related to lambda use in default configuration have changed.

Tricky features are:

  • parser is modified for lambda syntax extensions.
  • In some cases, abilities may not be inferred well yet, so examples may need to be over-annotated with abilities.
  • in ty.rs: unification checks Fun abilities as well as other things.
  • in lambda_lifter.rs, we (1) reject lambdas without move free-var handling, (2) try to reduce lambda to curry, by checking for a simple function call with simple args, the last of which are identical to the lambda parameters.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Copy link

trunk-io bot commented Sep 28, 2024

⏱️ 2h 37m total CI duration on this PR
Slowest 15 Jobs Cumulative Duration Recent Runs
rust-move-unit-coverage 17m 🟩
rust-cargo-deny 15m 🟩🟩🟩🟩🟩 (+4 more)
rust-move-tests 13m 🟥
general-lints 12m 🟩🟩🟩🟩🟩 (+4 more)
rust-move-unit-coverage 12m 🟩
rust-move-unit-coverage 11m 🟩
rust-move-tests 10m 🟩
rust-move-tests 9m 🟩
check-dynamic-deps 8m 🟩🟩🟩🟩🟩 (+4 more)
rust-move-tests 8m 🟥
rust-move-unit-coverage 5m 🟥
rust-move-unit-coverage 4m 🟥
rust-move-unit-coverage 4m 🟥
rust-move-unit-coverage 4m 🟥
rust-move-unit-coverage 3m 🟥

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link

codecov bot commented Sep 28, 2024

Codecov Report

Attention: Patch coverage is 79.67290% with 87 lines in your changes missing coverage. Please review.

Please upload report for BASE (09-27-extend_parser_for_lambda_types@243ea0f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
third_party/move/move-compiler/src/parser/ast.rs 24.2% 25 Missing ⚠️
...hird_party/move/move-compiler/src/expansion/ast.rs 25.0% 24 Missing ⚠️
third_party/move/move-model/src/exp_rewriter.rs 55.8% 15 Missing ⚠️
third_party/move/move-model/src/ty.rs 56.5% 10 Missing ⚠️
third_party/move/move-model/src/ast.rs 50.0% 7 Missing ⚠️
...arty/move/move-compiler/src/expansion/translate.rs 96.2% 4 Missing ⚠️
...piler-v2/src/env_pipeline/unused_params_checker.rs 92.3% 1 Missing ⚠️
...d_party/move/move-model/src/builder/exp_builder.rs 98.4% 1 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                           @@
##             09-27-extend_parser_for_lambda_types   #14792   +/-   ##
=======================================================================
  Coverage                                        ?    59.9%           
=======================================================================
  Files                                           ?      852           
  Lines                                           ?   207826           
  Branches                                        ?        0           
=======================================================================
  Hits                                            ?   124528           
  Misses                                          ?    83298           
  Partials                                        ?        0           
Flag Coverage Δ
59.9% <79.6%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from 7f59256 to ae73f37 Compare September 30, 2024 17:09
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from dbd482d to 270214e Compare September 30, 2024 17:09
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from ae73f37 to 243ea0f Compare September 30, 2024 18:43
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from 270214e to afbad9b Compare September 30, 2024 18:44
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from 243ea0f to f3d30eb Compare October 3, 2024 01:42
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from a40a3c9 to 71ef91f Compare October 3, 2024 01:43
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from f3d30eb to 0cc6890 Compare October 3, 2024 01:52
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from 71ef91f to 3a1d362 Compare October 3, 2024 01:53
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from 0cc6890 to 1b54f30 Compare October 3, 2024 04:42
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch 2 times, most recently from c46a244 to b3c1106 Compare October 3, 2024 06:09
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from ad600f0 to 017f471 Compare October 3, 2024 17:01
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from b3c1106 to a65ee0f Compare October 3, 2024 17:01
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from 017f471 to b7d429a Compare October 10, 2024 04:18
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from a65ee0f to cbb77b0 Compare October 10, 2024 04:18
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from b7d429a to c99de22 Compare October 10, 2024 05:25
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from cbb77b0 to b2185c2 Compare October 10, 2024 05:25
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from c99de22 to d3254ad Compare October 18, 2024 18:03
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from b2185c2 to 3f98e56 Compare October 18, 2024 18:04
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from d3254ad to 7e21319 Compare October 18, 2024 18:08
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from 3f98e56 to e24bf4e Compare October 18, 2024 18:08
@brmataptos brmataptos force-pushed the 09-27-extend_parser_for_lambda_types branch from 7e21319 to 7cfe2c4 Compare October 21, 2024 07:10
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from e24bf4e to 2a740e8 Compare October 21, 2024 07:10
Base automatically changed from 09-27-extend_parser_for_lambda_types to main October 21, 2024 07:48
@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from 2a740e8 to dabc427 Compare October 26, 2024 00:05
third_party/move/move-binary-format/src/file_format.rs Outdated Show resolved Hide resolved
third_party/move/move-binary-format/src/file_format.rs Outdated Show resolved Hide resolved
@@ -1739,6 +1814,12 @@ impl ExpRewriterFunctions for LoopNestRewriter {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Operation {
MoveFunction(ModuleId, FunId),
/// Build a closure by binding 1 or more leading arguments to a function value.
/// First argument to the operation must be a function; the reamining
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: reaming -> remaining

Copy link
Contributor

@vineethk vineethk left a comment

Choose a reason for hiding this comment

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

Submitting what I have as I saw some updates to the PR last night. Will continue reviewing.

/// fields,
/// } = self;
/// ...
/// impl AstDebug for StructDefinition {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: unnecessary whitespace change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Undone.

@@ -1901,9 +1902,35 @@ fn at_start_of_exp(context: &mut Context) -> bool {
)
}

// Parse the rest of a lambda expression, after already processing any capture designator (move/copy).
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have the (pseudo) grammar documented, similar to other parse_* functions around here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

} else {
// token is Tok::PipePipe, i.e., empty bind list in this context.
consume_token(context.tokens, Tok::PipePipe)?;
spanned(context.tokens.file_hash(), start_loc, start_loc + 1, vec![])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is start_loc + 1 the correct value for end (because "||" is 2 chars)?

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 guess so. This code was just moved up from parse_exp.

Copy link
Contributor

Choose a reason for hiding this comment

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

@brmataptos I don't think this is correct. If you see other usages, end is context.tokens.previous_end_loc() (and this is start_loc + len of token).

So we should either make this start_loc + 2 or use context.tokens.previous_end_loc() like elsewhere.

};
let body = Box::new(parse_exp(context)?);
let abilities_start = context.tokens.start_loc();
let abilities = parse_with_abilities(context)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add a test where we use has instead of with for declaring abilities of a lambda (which I expect would be a common mistake to do, given all our previous ability declarations were with has)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, added lambda/storable/parse_errors.move to put some parse errors like this.

if !abilities.is_empty() {
let abilities_end = context.tokens.previous_end_loc();
let loc = make_loc(context.tokens.file_hash(), abilities_start, abilities_end);
require_move_2(context, loc, "Abilities on function expressions");
Copy link
Contributor

Choose a reason for hiding this comment

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

We would want to gate this with a higher language version (not just 2.0), say 2.2 at least (2.1 is the current stable language version).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to 2.2

@@ -2209,6 +2250,10 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result<Exp, Box<Diagnostic
consume_token(context.tokens, Tok::RBracket)?;
exp
},
Tok::LParen => {
let args = parse_call_args(context)?;
Exp_::ExpCall(Box::new(lhs), args)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add some tests where we mix dot/index chains with call expressions? func_vector[0]() etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some tests to registry_ok.move to illustrate.

These will not run due to reentrancy, but are ok for now.

@@ -2443,11 +2488,18 @@ fn parse_type(context: &mut Context) -> Result<Type, Box<Diagnostic>> {
Type_::Unit,
)
};
let abilities_start = context.tokens.start_loc();
Copy link
Contributor

Choose a reason for hiding this comment

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

Update doc string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

if !abilities.is_empty() {
let abilities_end = context.tokens.previous_end_loc();
let loc = make_loc(context.tokens.file_hash(), abilities_start, abilities_end);
require_move_2(context, loc, "Ability constraints on function types");
Copy link
Contributor

Choose a reason for hiding this comment

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

Lang version at least 2.2 instead of 2.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// Parse an optional "with" type constraint:
// WithAbilities =
// ( "with" <Ability> (+ <Ability>)* )?
fn parse_with_abilities(context: &mut Context) -> Result<Vec<Ability>, Box<Diagnostic>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the PR description (at the very beginning), it says syntax is extended with the following: move |args| body with copy, store. But it looks like we use + (not ,) as the separator for abilities in both lambda expressions and types. Just double checking that this is what is intended and the PR description was a typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the PR description.

@@ -689,7 +717,7 @@ pub enum Exp_ {
// { seq }
Block(Sequence),
// | x1 [: t1], ..., xn [: tn] | e
Lambda(TypedBindList, Box<Exp>),
Lambda(TypedBindList, Box<Exp>, LambdaCaptureKind, Vec<Ability>),
Copy link
Contributor

Choose a reason for hiding this comment

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

update comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@vineethk vineethk self-requested a review November 26, 2024 01:46
}

public fun test_functions() {
// let sum = vector[];
Copy link
Contributor

Choose a reason for hiding this comment

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

stray comment?

@@ -978,7 +978,8 @@ impl<'env> ExpRewriterFunctions for SimplifierRewriter<'env> {
let ability_set = self
.env()
.type_abilities(&ty, self.func_env.get_type_parameters_ref());
ability_set.has_ability(Ability::Drop)
// Don't drop a function-valued expression so we don't lose errors.
Copy link
Contributor

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 corresponding to this?

@@ -14,14 +14,16 @@
//!
//! Lambda lifting rewrites lambda expressions into construction
//! of *closures*. A closure refers to a function and contains a partial list
//! of arguments for that function, essentially currying it. Example:
//! of arguments for that function, essentially currying it. We use the
//! `EarlyBind` operation to construct a closure from a function and set of arguemnts,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//! `EarlyBind` operation to construct a closure from a function and set of arguemnts,
//! `EarlyBind` operation to construct a closure from a function and set of arguments,

// If final `args` match `lambda_params`, and all other args are simple, then returns
// the simple prefix of `args`.
fn get_args_if_simple<'b>(
lambda_params: &Vec<Parameter>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lambda_params: &Vec<Parameter>,
lambda_params: &[Parameter],

@@ -96,7 +96,7 @@ fn generate_output(target: &FunctionTarget, test_output: &mut String) -> Option<
};
*test_output += &format!(
"--- Raw Generated AST\n{}\n\n",
exp.display_for_fun(target.func_env.clone())
exp.display_for_fun(target.func_env)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can do the same (removing .clone()) for two more instances below (assign-transformed and var-bound).

@@ -48,7 +48,7 @@ error: expression construct not supported in specifications
69 │ ensures RET = {let y = x; y + 1};
│ ^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot pass `|(num, num)|num` to a function which expects argument of type `|(num, num)|bool`
error: cannot pass `|(num, num)|num with copy+drop+store` to a function which expects argument of type `|(num, num)|bool`
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could remove abilities (with copy+drop+store) from the type error message if the error is not due to abilities mismatch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is harder than it looks, in general at least. This will require changing the type unification algorithm to build an explanation when a difference is found.

I filed #15414.

│ Expected ';'
│ ^

error: expected `|(integer, integer)|_` but found a value of type `integer`
Copy link
Contributor

Choose a reason for hiding this comment

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

the description of expected is likely not intuitive to the user: should it not be |integer, integer| instead of |(integer, integer)|_?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function doesn't exist. We don't know the return type here, so it is written as _.

We can improve this, but it shouldn't be in this PR, as it will change all test outputs.

Filed #15415

name.display(env.symbol_pool())
),
// TODO(LAMBDA)
"Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall."
"Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline function call."

}

// Only allow simple expressions which cannot vary or abort
fn exp_is_simple(fn_exp: &Exp) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: fn_exp -> exp?

Copy link
Contributor

Choose a reason for hiding this comment

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

We are using "simple" in two different contexts: arg being simple, and expression being simple. Can we use different terms here to avoid confusion?

None
}

// Only allow simple expressions which cannot vary or abort
Copy link
Contributor

Choose a reason for hiding this comment

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

What is an expression that can "vary"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A function call. I also don't want things to be too expensive, in case pulling them out of the lambda changes semantics. I changed the comment to indicate that.

If we weren't in rust, then I might be worried about a value that has references taken, but reference semantics should take care of that:

Copy link
Contributor Author

@brmataptos brmataptos left a comment

Choose a reason for hiding this comment

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

i've just pushed a new commit a moment ago to this PR.

I think I've addressed all reported issues, but I see 3 outstanding issues, seen by looking at lambda/storable/*_ok.lambda..exp:

  • some confusion between supported/implemented which is fixed in a stacked PR
  • function values not allowed as field types (also for later PR)
  • function types not allowed as type arguments (also for later PR)

I originally thought I could allow function calls to intermingle with . and [...] as in Rust (see Rust expression precedence allowing registry.functions[i].f(x) where f is a field of function type, but the simple approach leads to this being interpreted as calling a method through receiver syntax.

Instead, I'm requiring that a function-value used as a function be in parentheses for MVP:

  • f(x)
  • (registry.functions[i].f)(x)
    Rust does better, but perhaps this be useful enough for now.

So, PTAL. And review and "resolve" any comments you made which are ok.

third_party/move/move-binary-format/src/file_format.rs Outdated Show resolved Hide resolved
@@ -689,7 +717,7 @@ pub enum Exp_ {
// { seq }
Block(Sequence),
// | x1 [: t1], ..., xn [: tn] | e
Lambda(TypedBindList, Box<Exp>),
Lambda(TypedBindList, Box<Exp>, LambdaCaptureKind, Vec<Ability>),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

third_party/move/move-binary-format/src/file_format.rs Outdated Show resolved Hide resolved
@@ -1901,9 +1902,35 @@ fn at_start_of_exp(context: &mut Context) -> bool {
)
}

// Parse the rest of a lambda expression, after already processing any capture designator (move/copy).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Lambda(NodeId, Pattern, Exp),
Lambda(NodeId, Pattern, Exp, LambdaCaptureKind, AbilitySet),
/// Represents a reference to a Move Function as a function value.
MoveFunctionExp(NodeId, ModuleId, FunId),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed as EarlyBind.

/// fields,
/// } = self;
/// ...
/// impl AstDebug for StructDefinition {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Undone.

if !abilities.is_empty() {
let abilities_end = context.tokens.previous_end_loc();
let loc = make_loc(context.tokens.file_hash(), abilities_start, abilities_end);
require_move_2(context, loc, "Ability constraints on function types");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -2209,6 +2250,10 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result<Exp, Box<Diagnostic
consume_token(context.tokens, Tok::RBracket)?;
exp
},
Tok::LParen => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, renamed it to parse_dot_or_index_or_call_chain. Also fixed the bug in the syntax comment.

@@ -2209,6 +2250,10 @@ fn parse_dot_or_index_chain(context: &mut Context) -> Result<Exp, Box<Diagnostic
consume_token(context.tokens, Tok::RBracket)?;
exp
},
Tok::LParen => {
let args = parse_call_args(context)?;
Exp_::ExpCall(Box::new(lhs), args)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some tests to registry_ok.move to illustrate.

These will not run due to reentrancy, but are ok for now.

@brmataptos brmataptos force-pushed the 09-27-add_parser_code_for_lambda_types branch from cead217 to 44baaf0 Compare November 27, 2024 10:24
@vineethk vineethk self-requested a review November 27, 2024 15:00
Copy link
Contributor

@vineethk vineethk left a comment

Choose a reason for hiding this comment

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

There is still one parser fix I have requested (setting of span location for || when parsing lambdas), but approving assuming that is fixed.

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.

5 participants