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

Assertation failure in comments with symbol suggestion #398

Open
Y-Less opened this issue Jan 6, 2019 · 3 comments
Open

Assertation failure in comments with symbol suggestion #398

Y-Less opened this issue Jan 6, 2019 · 3 comments

Comments

@Y-Less
Copy link
Member

Y-Less commented Jan 6, 2019

Issue description:

Minimal complete verifiable example (MCVE):

comments.p:

/*
	Y_Less
	koolk
	JoeBullet/Google63
	g_aSlice/Slice
	Misiur
	samphunter
	tianmeta
*/

static
  	a,
	b;

main.p:

#include "comments.p"

main()
{
	__LINE();
}

As far as I have been able to derive. Everything there is required - even the comments and spacing! Just removing one name from that list compiles "correctly" (i.e. gives errors). And I just realised why, the assertion failure is:

errstart <= fline

so I think the problem is related to the relative lengths of the files.

Workspace Information:

  • Compiler version: 3.10.9
  • Command line arguments provided (or sampctl version):
  • Operating System:
@stale
Copy link

stale bot commented Apr 6, 2019

This issue has been automatically marked as stale because it has not had recent activity.

@stale stale bot added the state: stale label Apr 6, 2019
@Daniel-Cortez
Copy link
Contributor

Daniel-Cortez commented Mar 5, 2021

Tried to simplify the MCVE as much as possible, got to the following:
test.inc:

/* 3 empty lines */


new a, b;// <= line 4

test.pwn:

#include "test.inc"
main(){}

In this example the compiler prints two warning 203: symbol is never used messages, for variables a and b.
Both warnings are displayed at the end of compilation process, when the compiler seeks for unused variables and functions to warn the user about them, so the value in fline is 3 (the number of the last line in test.pwn).
When error() is called for the first time (for variable a):

  • the value in errstart is -1 (the number of the starting line for the error/warning message is not defined yet);
  • expression errstart<=fline results in 1 (-1 is less than 3), the corresponding assertion doesn't get triggered;
  • errstart is assigned value 4 (the line variable a is defined on in test.inc).

Then when error() is called again (this time for variable b):

  • the value in errstart is still 4 (assigned at the previous function call);
  • assertion errstart<=fline gets triggered, as 4 is greater than 3.

I think the fix should involve introducing a new local variable in function error(), which would be used instead of variable errstart, so errstart wouldn't be modified inside error().

@stale stale bot removed the state: stale label Mar 5, 2021
Daniel-Cortez added a commit to Daniel-Cortez/pawn-3.10 that referenced this issue Mar 6, 2021
…__pragma` tests

This was another manifestation of the bug reported in pawn-lang#398.
@stale
Copy link

stale bot commented Jun 22, 2021

This issue has been automatically marked as stale because it has not had recent activity.

@stale stale bot added the state: stale label Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants