compiler crashing when not using () for a methodmap's native
When not using () to call the native, the compiler crashes and doesn't manage to compile the code. For example here with entitylump:
for(int i = 0; i < EntityLump.Length; i++)
This crashes the compiler because the method "Length` is a native and not a property. considering that most methodmaps use this name as a property which led me to use it without () thinking it was a property
But when using:
for(int i = 0; i < EntityLump.Length(); i++)
The compiler works fine as expected and the code manages to be compiled.
Compiler Version: SourcePawn Compiler 1.12.0.7210 Copyright (c) 1997-2006 ITB CompuPhase Copyright (c) 2004-2024 AlliedModders LLC
Do you have an example script? I can't repro with:
methodmap Blah {
public int Length() { return 2; }
}
public void main() {
Blah blah;
for (int i = 0; i < blah.Length; i++) {
}
}
Output:
test.sp(7) : error 050: missing function call, cannot use non-static member function as a value
7 | for (int i = 0; i < blah.Length; i++) {
-----------------------------------^
1 Error.
Do you have an example script? I can't repro with:
methodmap Blah { public int Length() { return 2; } } public void main() { Blah blah; for (int i = 0; i < blah.Length; i++) { } }Output:
test.sp(7) : error 050: missing function call, cannot use non-static member function as a value 7 | for (int i = 0; i < blah.Length; i++) { -----------------------------------^ 1 Error.
I guess it only happens for static methods/members
Try using EntityLump's methodmap, the compiler will crash. If you removed static from the Length native, it will work just fine and throw an error like in your example.
(Sorry for the late reply)