Skip to content

[FEATURE] Support for local static variables #321

@Starexify

Description

@Starexify

Standard Haxe supports local static variables within functions to persist data between calls (as documented in the Haxe Manual).

Say we have this example code:

static function getData() {
		static var cache:Null<String> = null;
		if (cache == null) {
			cache = slowOperation();
		}
		return cache;
	}

	static function slowOperation() {
		trace("performing slow operation...");
		return "result";
	}

	static public function main() {
		trace(getData()); // performing slow operation... result
		trace(getData()); // result
	}

In haxe environments (expected behavior) we get this result:

performing slow operation... result
result
result

But in polymod this happens:

 ERROR  Error while parsing script assets/scripts/WorstCParser.hxc#11: EUnexpected
Unexpected error: Unexpected token "var", is there invalid syntax on this line?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions