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

feat: add to allow use comments in other scopes that is not from a function #454

Merged
merged 4 commits into from
Nov 20, 2023

Conversation

NiumXp
Copy link
Contributor

@NiumXp NiumXp commented Nov 15, 2023

Fixes #434.

Now the users can do whaterver they want with comments that is not in a function or in the middle of a instruction/line:

struct {
	// points is to something
	int	points; // is an int :D
};

void hello(/* nothing */ void) // error because comment is in middle of the line
{
   // error because scope is from a function
   {
      // are you trying to cheat?
      // error because scope is from a function
   }
}; 

@NiumXp
Copy link
Contributor Author

NiumXp commented Nov 15, 2023

Just adding some a know bug here:

void hello(void)
{
	/* 1 */ /* 2 */ /* 3 */ // 4
}
Error: INVALID_HEADER       (line:   1, col:   1):      Missing or invalid 42 header
Error: SPACE_BEFORE_FUNC    (line:   1, col:   5):      space before function name
Error: WRONG_SCOPE_COMMENT  (line:   3, col:   5):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  13):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  13):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  21):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  21):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  21):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  29):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  29):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  29):      Comment is invalid in this scope
Error: WRONG_SCOPE_COMMENT  (line:   3, col:  29):      Comment is invalid in this scope

The first comment triggers one error, the second triggers two, ..., btw, I don't think this can be an issue since it only appears in this specific scenario that is not usual

Copy link
Contributor

@matthieu42Network matthieu42Network left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the code in the description as a test?
And I agree about the multiplication of errors it's not a usual scenario.

@matthieu42Network matthieu42Network merged commit a08d048 into 42School:master Nov 20, 2023
4 checks passed
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

Successfully merging this pull request may close these issues.

Struct comments
2 participants