Cannot cast this expression

A cast expression needs one argument: the object reference to cast. In this case, either zero or too many arguments were specified.

This error can also occur if you want to call a function, but the name of the function is also used as a class name. Because casts take precedence over function calls, the compiler converts this into a cast. In this case, you need to rename the function.

Here is an example that triggers the error twice:

class Test {
}

int func test()
  return 0
endfunc
  
Object obj = new Test
Test t = Test(obj, obj)  ; Error!
int x = test()           ; Error, treated as a cast

To fix this, specify one argument in the cast, and rename the function so it can be called:

int func test2()
  return 0
endfunc
  
Object obj = new Test
Test t = Test(obj)  ; OK
int x = test2()     ; Treated as function call

See Also
Errors