polserver/testsuite/escript/classes/method-new.src
Kevin Eady 8b41711a6d Fix funcref.new(); Correctly error on accessing class name as identifier (#716)
* Fix funcref.new on non-ctors

* Properly error on accessing class name as identifier
2024-10-10 18:06:04 +02:00

36 lines
902 B
Text

// Test MTH_NEW call on a funcref that is not a ctor for both class and non-class methods
class ClassA()
function ClassA( this, arg0 )
this.arg0 := arg0;
endfunction
function stringify( this )
return $"ClassA::stringify this={this} this.arg0={this.arg0}";
endfunction
function staticfunc()
endfunction
endclass
function GlobalFunction()
endfunction
print( @ClassA.new() );
print( @ClassA.new( "a0" ) );
print( @ClassA.new( "a0", "a1" ) );
// (a) class method
print( @ClassA::stringify.new() );
print( @ClassA::stringify.new( "a0" ) );
print( @ClassA::stringify.new( "a0", "a1" ) );
// (b) global function
print( @GlobalFunction.new() );
print( @GlobalFunction.new( "a0" ) );
print( @GlobalFunction.new( "a0", "a1" ) );
// (c) class static function
print( @ClassA::staticfunc.new() );
print( @ClassA::staticfunc.new( "a0" ) );
print( @ClassA::staticfunc.new( "a0", "a1" ) );