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

Inconsistent precedence of user-defined functions #210

Open
cardillan opened this issue Jan 21, 2025 · 0 comments
Open

Inconsistent precedence of user-defined functions #210

cardillan opened this issue Jan 21, 2025 · 0 comments
Labels
compiler Related to the code generator

Comments

@cardillan
Copy link
Owner

When a user-defined functions shadows a built-in one, the built-in one is chosen in compile-time expression evaluation, while a user-defined one is chosen to compile non-constant expressions:

param a = 90; // Prevents compile-time evaluation

def sin(x)
    x * x;
end;

begin
    println(sin(90));
    println(sin(a));        
    printflush(message1);
end;

produces

1
8100

The issue won't be fixed until modules and namespaces are introduced, at which time some mechanism for accessing shadowed built-in functions gets implemented.

The workaround is to avoid functions that shadow existing built-in functions.

@cardillan cardillan changed the title Unclear precedence of user-defined functions Inconsistent precedence of user-defined functions Jan 21, 2025
@cardillan cardillan added the compiler Related to the code generator label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Related to the code generator
Projects
None yet
Development

No branches or pull requests

1 participant