compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Assertation failure in comments with symbol suggestion

Open Y-Less opened this issue 7 years ago • 3 comments

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:

Y-Less avatar Jan 06 '19 13:01 Y-Less

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

stale[bot] avatar Apr 06 '19 14:04 stale[bot]

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().

Daniel-Cortez avatar Mar 05 '21 16:03 Daniel-Cortez

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

stale[bot] avatar Jun 22 '21 17:06 stale[bot]