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

[Spec Deviation] Actions nested inside other actions #17993

Closed
MaryamZi opened this issue Aug 19, 2019 · 4 comments · Fixed by #22816
Closed

[Spec Deviation] Actions nested inside other actions #17993

MaryamZi opened this issue Aug 19, 2019 · 4 comments · Fixed by #22816
Assignees
Labels
Area/Compiler Spec/2019R3 Related to Ballerina Spec 2019R3 Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/SpecDeviation

Comments

@MaryamZi
Copy link
Member

Description:
The 2019r3 spec says

"Actions are an intermediate syntactic category between expressions and statements. Actions are similar to expressions, in that they yield a value. However, an action cannot be nested inside an expression; it can only occur as part of a statement or nested inside other actions. This is because actions are shown in the sequence diagram in the graphical syntax."

Steps to reproduce:
The following is not allowed though.

type Foo client object {
    
    remote function abc() returns int {
        return 1;
    }

    remote function def(int i) returns string {
        return "str";
    }
};

public function main() {
    Foo f = new;
    string s = f->def(f->abc());
}
$ ballerina run test.bal 
error: .::test.bal:14:23: action invocation as an expression not allowed here

Affected Versions:
1.0.0-beta-SNAPSHOT - 15th August build

@MaryamZi MaryamZi added Area/Compiler Type/SpecDeviation Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Aug 19, 2019
@pubudu91 pubudu91 added the Spec/2019R3 Related to Ballerina Spec 2019R3 label Oct 17, 2019
@pubudu91 pubudu91 added this to the Ballerina 1.1.0 milestone Oct 17, 2019
@hasithaa hasithaa removed this from the Ballerina 1.1.0 milestone Dec 20, 2019
@rdhananjaya rdhananjaya added the Points/3 Equivalent to three days effort label Apr 2, 2020
@pubudu91
Copy link
Contributor

Just realized, the above scenario cannot be allowed according to the spec right? The remote method call is defined as follows:

remote-method-call-action := expression -> method-name ( arg-list )

And the arg-list is defined as follows:

arg-list :=
positional-args [, other-args]
| [other-args]
positional-args := positional-arg (, positional-arg)*
positional-arg := expression
other-args := named-args | rest-arg
named-args := named-arg (, named-arg)*
named-arg := arg-name = expression
arg-name := identifier
rest-arg := ... expression

An action invocation cannot be an argument according to the above right?

@MaryamZi
Copy link
Member Author

Yeah, according to the current spec grammar this doesn't seem valid. But should we check on the possibility of allowing this, as discussed offline?

@pubudu91
Copy link
Contributor

Yeah, +1. IIRC, this issue was created because someone asked about nesting and chaining.

@pubudu91 pubudu91 removed the Points/3 Equivalent to three days effort label Apr 16, 2020
@pubudu91 pubudu91 linked a pull request Apr 16, 2020 that will close this issue
13 tasks
@pubudu91 pubudu91 added this to the Ballerina 1.3.0 milestone Apr 16, 2020
@pubudu91
Copy link
Contributor

Since the specific scenario is not allowed as per the spec, left it out. A limited number of of actions that can be nested, was left allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Compiler Spec/2019R3 Related to Ballerina Spec 2019R3 Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/SpecDeviation
Projects
None yet
4 participants