polserver/testsuite/escript/classes/scopes-02.src
Kevin Eady 0fa1b893a0 Update core-changes, break-changes for classes support (#719)
* Format testsuite escript

* Format testsuite pol

* Update docs
Switch "attributes" to "members" to better align with Escript terms.

* Add core-changes, breaking-changes
2024-10-10 18:06:04 +02:00

20 lines
576 B
Text

// Animal::StaticFunc refers to itself without scope. It should prefer its own definition over ::StaticFunc.
// ::StaticFunc is defined and referenced before Animal::StaticFunc, so this ensures that the function resolver
// does not link the (already-referenced) global function.
function StaticFunc( foo )
print( $"::StaticFunc foo={foo}" );
endfunction
StaticFunc( "bar" );
class Animal()
function StaticFunc( foo )
if ( foo )
print( $"Animal::StaticFunc foo={foo}" );
StaticFunc( foo - 1 );
endif
endfunction
endclass
Animal::StaticFunc( 3 );