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

Internal error: global void variable #27

Open
derrell opened this issue Oct 13, 2014 · 3 comments
Open

Internal error: global void variable #27

derrell opened this issue Oct 13, 2014 · 3 comments
Labels

Comments

@derrell
Copy link
Owner

derrell commented Oct 13, 2014

This program generates an internal error. Note void global variable and incorrect syntax for draw_greenSquare function definition.

#include <stdio.h>
#include <draw.h>

void draw_green;

int main(int argc, char * argv[])
{     
    draw_greenSquare();
    return 0;
}

void draw_greenSquare
{
}
@derrell derrell added the bug label Oct 13, 2014
@ebertmi
Copy link

ebertmi commented Oct 14, 2014

There must be an error with the function definition, I think the current implementation of the grammar allows the parsing of the malformed function definition.

@derrell
Copy link
Owner Author

derrell commented Oct 14, 2014

Can you clarify? I'm not sure what you're saying.

If you're saying that it is valid to define a function as

void draw_greenSquare
{
}

then no, I don't believe that's the case (in ANSI C, which is what LearnCS! supports). The argument list parenthesis are required, and if no arguments, then the argument list must contain the keyword void.

The one I need to research is void draw_green; which doesn't make any intuitive sense (what storage size would it be?), but I'm not sure whether it's legal. (And if it's legal, what does it mean? I'm almost certain it's not legal.)

Regardless, a proper error message should be generated, not an internal error.

@ebertmi
Copy link

ebertmi commented Oct 14, 2014

Yes I wanted to state out, that the the function definition without parenthesis is incorrect however gets parsed and produces no grammar error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants