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

Defining struct in a loop gives confusing error message #443

Open
user202729 opened this issue Apr 26, 2024 · 1 comment
Open

Defining struct in a loop gives confusing error message #443

user202729 opened this issue Apr 26, 2024 · 1 comment

Comments

@user202729
Copy link

for(int i=0; i<10; ++i){
	struct A{int x;}
	A f(A a, int y){ a.x+=i; return a; }
	A a;
	A b=f(a,1);
}

Error message:

        A b=f(a,1);
      ^
a.asy: 5.7: cannot cast 'A' to 'A'
success

Why is the f function not redefined anyway?

@johncbowman
Copy link
Member

For the record, here's a more minimal example:

while(true) {
  struct A {
    int x;
  }
  A f(A a){ return a; }
  A a;
  a=f(a);
}

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

No branches or pull requests

2 participants