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

Using same name for procedure and its argument leads to wrong code #9

Open
wipe2238 opened this issue Jul 12, 2023 · 0 comments
Open

Comments

@wipe2238
Copy link

procedure stuff(variable stuff, variable in_recursion := 0)
begin
  if not(in_recursion) then
   stuff := stuff(stuff, 1);
  else
  begin
     display_msg("doing critical stuff");
     stuff++;
     return stuff;
  end
end

procedure start begin call stuff(0); end

According to int2sll it compiles to

procedure stuff(variable arg0, variable arg1);
procedure start;

procedure stuff(variable arg0, variable arg1)
begin
    if (not(arg1)) then begin
        arg0 := arg0(arg0, 1); // wait what...
    end
    else begin
        display_msg("doing critical stuff");
        arg0 := arg0 + 1;
        return arg0;
    end
end

procedure start
begin
    call stuff(0, 0);
end
@wipe2238 wipe2238 changed the title Using same name for procedue and its argument leads to wrong code Using same name for procedure and its argument leads to wrong code Jul 12, 2023
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

1 participant