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

Calling a lib function of accessing field inside a binary expression causses an error #418

Closed
mkarten opened this issue Sep 30, 2024 · 1 comment · Fixed by #419
Closed
Assignees
Labels
bug Something isn't working fix asap need to be reviewed and fixed as fast as possible parser issue concerning the parser part

Comments

@mkarten
Copy link
Member

mkarten commented Sep 30, 2024

import "math";
import "console";

var x float = 1.0;
var cosX float = 2 + math.cos(x) + 1;

console.println(cosX);

in this code we call the math.Cos inside a binary expression
this result in the error :

Fatal Error Line: 5, Col: 37
cannot use math here

this is caused by the binary expression not parsing when encountering the selector expression and continuing to parse a selector instead of the correct binary expression

@mkarten mkarten added bug Something isn't working fix asap need to be reviewed and fixed as fast as possible parser issue concerning the parser part labels Sep 30, 2024
@mkarten mkarten self-assigned this Sep 30, 2024
@mkarten mkarten added this to Ecla Sep 30, 2024
@github-project-automation github-project-automation bot moved this to Todo in Ecla Sep 30, 2024
@mkarten
Copy link
Member Author

mkarten commented Sep 30, 2024

the error also occurs when we access a field inside a binary expression

import "console";

struct Point {
    x: float;
    y: float;
}

function TestPoint(p: Point) {
    var calc float = p.x + p.y;
    console.println(calc);
}

var p Point = Point{1.0, 2.0};

TestPoint(p);

it produces the error :

Fatal Error Line: 9, Col: 31
struct cannot have filed of type Point

@mkarten mkarten changed the title Calling a lib function inside a binary expression causses an error Calling a lib function of accessing field inside a binary expression causses an error Sep 30, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Ecla Oct 2, 2024
mkarten added a commit that referenced this issue Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix asap need to be reviewed and fixed as fast as possible parser issue concerning the parser part
Projects
Status: Done
1 participant