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

"default" can't be used as a function parameter #69

Closed
mccain opened this issue Feb 2, 2015 · 1 comment
Closed

"default" can't be used as a function parameter #69

mccain opened this issue Feb 2, 2015 · 1 comment
Assignees

Comments

@mccain
Copy link
Contributor

mccain commented Feb 2, 2015

class Main
    def fun_with_def(num: int, default: int): void {
        if (num >= 0)
        then print num
        else print default
    }
    def main() : void {
        this.fun_with_def(1, 42);
    }

Fails to compile with the following errors:

default_src/Main.pony.c:84:50: error: expected ')'
void* Main_fun_with_def(Main_data* this, int64_t default)
                                                 ^
default_src/Main.pony.c:84:24: note: to match this '('
void* Main_fun_with_def(Main_data* this, int64_t default)
                       ^
default_src/Main.pony.c:84:50: error: parameter name omitted
void* Main_fun_with_def(Main_data* this, int64_t default)
                                                 ^
default_src/Main.pony.c:88:20: error: expected expression
  printf("%lli\n", default);
                   ^
3 errors generated.
 *** Compilation failed with exit code 1 ***
@EliasC
Copy link
Contributor

EliasC commented Feb 2, 2015

Ah yes, I'm guessing any argument name that is a keyword in C (break, for, typedef etc.) will cause this bug. Good catch! I would suggest misspelling default (dflt?) for now ;)

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

3 participants