DMX4001: Dart 3.13 primary constructors reported as invalid Dart

Open
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
dart, rust
Domain
tooling

Research direction

Start with the dmx build and dmx watch entry points and reproduce the failure against a .dart file containing a Dart 3.13 primary constructor. Trace how every .dart file under lib/ is parsed, then verify that primary constructors parse successfully and that an unrelated unannotated file no longer blocks annotated generation or watch runs.

Written by the indexing model from the issue text.

Description

Summary

dmx 0.3.0 reports DMX4001: input is not valid Dart on files that compile with Dart 3.13. The parser does not accept primary constructors (class const Foo(...) / class Foo(...)).
Because dmx build / dmx watch parse every .dart file under the given path (not only @dmx(...) classes), a single primary constructor anywhere in lib/ makes a project-wide generate/watch run fail.

Environment

  • dmx: 0.3.0 (VS Code extension bundled CLI, also used from terminal)
  • Dart: 3.13.0
  • Flutter: 3.47.0
  • OS: macOS (Apple Silicon)

Reproduction

  1. Create a file that is valid Dart 3.13, with no @dmx annotation:
class const ZipAddressModel({
  required final String pref,
  required final String city,
  required final String town,
});
  1. Run:
dmx build lib --insert-regions
# or
dmx watch lib

Actual

error: DMX4001: input is not valid Dart at line 2, column 13

The column points at const in class const ZipAddressModel({.
The same error appears on every primary-constructor class in the tree, for example:

error: lib/core/api/api.dart: DMX4001: input is not valid Dart at line 524, column 13
error: lib/features/wallet/schemas/zip_address_model.dart: DMX4001: input is not valid Dart at line 2, column 13

dmx watch lib still prints dmx: watching 1 path(s), but those files never get a usable parse.
dart analyze on the same files reports no issues.

Expected

  • Dart 3.13 primary constructors should parse as valid input.
  • Files without @dmx(...) should not block generate/watch for annotated classes in the same tree.
  • Alternatively, build / watch should skip files they cannot (yet) parse, instead of failing the whole run.

Workaround

Point dmx at a single experimental file instead of the whole lib/ directory:

dmx build path/to/annotated_file.dart --insert-regions
dmx watch path/to/annotated_file.dart

That is not viable for a real app whose lib/ already uses primary constructors.

Notes

Related, but separate: DMX2001 requires an explicit type on fields such as final _fieldKey = GlobalKey<...>(). That is valid inferred Dart; calling out in case the parser is intentionally stricter than the language.
Happy to provide a minimal repo if useful.

Dominant language
Rust
Stars
21
Forks
0
Avg merge
7m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Nimblesite/dmx

All issues in Nimblesite/dmx

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.