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

gets stuck in an infinit loop when a function gets called without a ; #493

Open
paulorsfaria opened this issue Apr 15, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@paulorsfaria
Copy link

paulorsfaria commented Apr 15, 2024

Describe the bug
when the last function called has no ; in the end "example()" the norminette gets stuck on an infinite loop.
This will only happen if there are no ; in the code following the function

Erroneous code
like this it will get stuck in a lop

int example()
{
	get_cost()
	return 1
}

but if you add a ; after the return norm will work correctly

int example()
{
	get_cost()
	return 1;
}

Additional infos
norminette 3.3.55

@veliga-syutkin
Copy link

+1

@Asandolo Asandolo added the bug Something isn't working label Jun 21, 2024
@ErrorRaffyline0
Copy link

ErrorRaffyline0 commented Jul 29, 2024

I found the same issue, however, it seems like the failure conditions are a little more complicated.

The loop only occurs when the last statement is a function without a semicolon. This is why, for example, Norminette does NOT execute a loop when you write statements such as return

int	test(void)
{
	return (1)
}

but if you only write a function such as write without ;, Norminette DOES execute a loop.

#include <unistd.h>

int	test(void)
{
	write(1, "42", 2)
}

If you write two or more subsequent functions without semicolons, Norminette won't get stuck in a loop, but instead
unceremoniously crash with "Error: Unexpected EOF l.7" (Unexpected end of file at line 7).

#include <unistd.h>

int	test(void)
{
	write(1, "Codam", 5)
	write(1, "42", 2)
}

This happens regardless of whether or not the functions are in the same statement body. Putting a semicolon ANYWHERE after a function without ; will prevent this behavior by terminating it. (You need more semicolons depending on the amount of erroneous functions you want to terminate, although for some weird reason it seems to terminate them all with one semicolon as long as you don't have an empty line at the end of the file.)

My best guess is that Norminette is hardcoded to process the file from top to bottom, and processes each line until she sees a semicolon. If she doesn't see one, she will loop if she doesn't encounter subsequent functions or semicolons, or she will process any function she sees afterward as if they were part of the offending line and then print lots of indentation, parenthesis, empty line, and other errors, or crash, depending on the syntax.

This would track with why she will complain about indentation here at line 7 and 12, and an empty line at line 10, because she is not aware that the statement body of loc was completed after the first function. (I end the file with a semicolon because otherwise Norminette would crash without useful error data.)

#include <unistd.h>

int	loc(void)
{
	write(1, "Codam", 5)
}

int test(void)
{
	write(1, "42", 2)
}
;

I hope this was any help because I spent way more time on this than I am willing to admit and I should really get back to speedrunning C in the Piscine lol.

Additional infos
Norminette 3.3.55 (According to French standards, Norminette's pronouns should be she/her unless otherwise specified)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants