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

Nested #if/#endif problems #989

Open
rtldg opened this issue Oct 27, 2024 · 0 comments
Open

Nested #if/#endif problems #989

rtldg opened this issue Oct 27, 2024 · 0 comments

Comments

@rtldg
Copy link
Contributor

rtldg commented Oct 27, 2024

Nested if/endif pairs used to work in SM 1.11 like this:

public void OnPluginStart()
{
#if 0
#if 0
	PrintToServer("foo bar");
#endif
#endif
}

In 1.12 (master branch of this repo) it does this:

> .\spcomp.exe .\test_if_endif.sp
SourcePawn Compiler 1.12
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2021 AlliedModders LLC

.\test_if_endif.sp(1) : error 001: expected token: "#endif", but found "-end of file-"

.\test_if_endif.sp(9) : error 030: compound statement not closed at the end of file (started at line 9)
     9 | }
----------^

2 Errors.

(or something like this with the latest sm 1.12 7164 build)

// H:\steamcmd\cstrike\cstrike\addons\sourcemod\scripting\include\entity_prop_stocks.inc(590) : error 030: compound statement not closed at the end of file (started at line 590)
//    590 | }
// ---------^
//
// .\test_if_endif.sp(1) : error 001: expected token: "#endif", but found "-end of file-"
//
// 2 Errors.
//
// Compilation Time: 0.22 sec
// ----------------------------------------

this will still error:

public void OnPluginStart()
{
#if 0
#if 1
	PrintToServer("foo bar");
#endif
#endif
}

this will work:

public void OnPluginStart()
{
#if 1
#if 0
	PrintToServer("foo bar");
#endif
#endif
}

This might:tm: be intended now but I expect that it's probably not

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

No branches or pull requests

1 participant