Repository navigation
v2.23.0 - Expose `nullSafetyChecks` through the CLI and MCP
2.22.0 added ApolloVM(nullSafetyChecks: true), but the only way to turn it on was to construct the VM in Dart. It is now reachable from every entry point that actually loads code.
CLI
--null-safety on run, translate and compile, added once on the shared CommandSourceFileBase alongside --pub:
$ apollovm run --null-safety foo.dart
** NULL SAFETY: Can't load `foo.dart` (dart): 1 null-safety error(s).
- The operand 'b' can be 'null', so it can't be used in an operation
unconditionally. Use '??', '!' or a null check.
$ echo $?
1
The rejection prints as a report rather than escaping as an unhandled error with a stack trace, and is not restated as a parse failure. main now maps a command result of false to exit status 1 so the flag can gate a build — no existing command path returns false.
MCP
Every source tool takes an optional nullSafety argument, and --null-safety on both mcp serve and mcp call sets the default (a per-call value always wins). The two tool kinds behave differently, by design:
- Tools that load —
execute,translate,wasm— reject the source, returning the findings as diagnostics rather than throwing. - Parse-based tools —
parse,ast,symbols,types— never callloadCodeUnit, so "fail the load" would be meaningless. They add the findings todiagnosticsand still succeed, which is the useful form for inspection: the problem is visible without executing anything.
$ apollovm mcp call parse -f foo.dart -l dart --null-safety
{ "ok": true,
"diagnostics": [ { "severity": "error",
"code": "unchecked-nullable-operand",
"message": "The operand 'b' can be 'null' ..." } ], ... }
The server default is merged into the tool arguments at the single dispatch point shared by the in-process and isolate paths. _IsolateJob carries only the arguments and limits, so a field on the server object would never reach a spawned isolate — and apollovm.execute runs in one by default. It is deliberately not stored in McpLimits, which is documented as resource/security limits.
Adds mcpCoerceBool beside mcpCoerceInt, so a client sending "true" or 1 is handled instead of crashing the tool on a hard cast — the same class of bug 2.16.0 fixed for the integer arguments.
Not changed: the LSP
Its Analyzer uses its VM only for getParser and never loads a code unit, and it already surfaces null-safety findings as diagnostics. An editor must report, not refuse to open a file.
Tests
2533 passing (from 2510), plus Chrome wasm-gc and wasm-chrome. New CLI coverage spawns the real script (bin/ cannot be imported); new MCP coverage checks both tool kinds, the server-default merge, the per-call override, mcpCoerceBool across its input forms, and the argument surviving the isolate boundary.