Sarrus1 / sourcepawn-studio

VSCode extension for SourcePawn scripting
https://sarrus1.github.io/sourcepawn-studio/
MIT License
143 stars 22 forks source link

Unknown Error in Format function #312

Closed moemoequte closed 1 year ago

moemoequte commented 1 year ago

Basic informations

Further Information

When I use FormatEx() like this image

it will shows an error, I dont know what this error means

After I delete the FormatEx() function, vscode will not shows the error image

But I can compile this code although the plugin tells me there is an error image

I use one line the error still occurs image

When code is very simple, the Format behave correct image

Sarrus1 commented 1 year ago

Hi, thanks for reporting the issue! Can you please post the code via text (whole project ideally) so that I can try to reproduce the error?

I assume that POSTGRESQL_ROOT_DB and ...SHOP_PLAYER are defines, which can cause a problem for the parser if the preprocessor did not work properly.

You can also try the Reveal preprocessed document (as seen by the server) command (CTRL+SHIFT+P and type Reveal preprocessed document (as seen by the server)) This should show what the parser sees and the syntax error will be apparent.

moemoequte commented 1 year ago

Hi, thanks for reporting the issue! Can you please post the code via text (whole project ideally) so that I can try to reproduce the error?

I assume that POSTGRESQL_ROOT_DB and ...SHOP_PLAYER are defines, which can cause a problem for the parser if the preprocessor did not work properly.

You can also try the Reveal preprocessed document (as seen by the server) command (CTRL+SHIFT+P and type Reveal preprocessed document (as seen by the server)) This should show what the parser sees and the syntax error will be apparent.

test.inc

#define URL "url"
#define PLAYER "player"

image

temp2.sp

#include <sourcemod>
#include <test>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    char url[256];
    Format(url, sizeof(url), "%s/%s,%d", URL, PLAYER, 5);
}

image

ERROR: image

Compile log

C:\Users\cialloo\sourcemodAPI\addons\sourcemod\scripting\spcomp.exe
c:\Users\cialloo\Desktop\backend\addons\sourcemod\scripting\temp2.sp 
-oc:\Users\cialloo\Desktop\backend\addons\sourcemod\plugins\temp2.smx 
-ic:\Users\cialloo\Desktop\backend\addons\sourcemod\scripting\include 
-ic:\Users\cialloo\Desktop\backend\addons\sourcemod\scripting 
-ic:\Users\cialloo\Desktop\backend\addons\sourcemod\scripting\include 
-iC:\Sourcemod\include 
-O2 -v2 

SourcePawn Compiler 1.11.0.6934
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2021 AlliedModders LLC

Code size:         3676 bytes
Data size:         2304 bytes
Stack/heap size:      16732 bytes
Total requirements:   22712 bytes

Done.

image