Skip to content

v2.1.1 - static class fields + parser/interpreter correctness fixes

Choose a tag to compare

@gmpassos gmpassos released this 18 Jul 04:07
· 158 commits to master since this release
5b9562f

static class fields are now supported

static fields previously had no class-level storage — they were initialized onto every instance, and reading one (ClassName.field, or a bare reference inside a static method) threw at runtime. Now each class has a lazily initialized static-field store, shared by qualified ClassName.field access and bare references inside the class's own static methods, for read, write and compound assignment. The Java and C# grammars also now record the static field modifier (they were dropping it), so this works across those languages too.

Correctness fixes (parser & interpreter)

  • Compound assignment ~/= no longer crashes the parser. ~/= (Dart) and //= (Python) matched the grammar but had no handler, so parsing threw an uncaught error out of loadCodeUnit. ~/=///= are now fully supported, and any other still-unsupported compound operator (e.g. JavaScript/TypeScript %=) surfaces as a clean SyntaxError instead of an uncaught crash.
  • Enum.values can be assigned to a typed or inferred list. It was built with a dynamic element type while its declared type is List<Enum>, so var v = Color.values; / List<Color> v = Color.values; failed the declaration cast. It now carries the enum's own element type.
  • ASTValue.fromValue<int> on a non-whole double now throws a clean ApolloVMCastException instead of a raw Dart TypeError.

Division semantics are unchanged and remain intentionally per-language (Dart/JS/TS/Python / yields a double; Java/C#/Go/Kotlin / on ints is truncating integer division); regression guards now pin both.

Full changelog: https://github.com/ApolloVM/apollovm_dart/blob/v2.1.1/CHANGELOG.md