The Monad language. Dependent types, functional programming compiled with LLVM. Hobby project. monad-lang.org
dependent-types language compiler programming-language functional-programming

lang+core: dot field access sugar for single-constructor types master

`a.fi` (and chains, `a.fi.fi2`) now desugars to `match a { {fi} => fi }` for any locally-bound value of a single-constructor type — `struct` or plain `type` alike. `a.fi` was already parsed as a dotted module path (`NameRef::P`): the parser has no scope info to tell a local variable apart from a module name. The fix lives entirely in name resolution, where the binder stack is actually available: - core/src/lower_core.rs: `lower_var`'s `NameRef::P` arm now checks `ctx.find_bound` on the path's first segment. If it's a local binding, synthesize the same bare-form field-pattern `Match` the parser already builds for destructured `def` params — one nested match per remaining segment (new `lower_field_access_chain` helper). Otherwise, falls through to the previous global-atom behavior unchanged. - lang/parser.mo: mirrors the same fix in `variable_try_path`, checking `find_index` against the threaded `ctx` before flattening a dotted path to a global reference. New `field_access_chain` helper reuses the `MatchCase`/`FieldPattern` shape `lam_parsed_params_loop` already builds for destructured params. Because this reuses the existing struct-field-destructuring pipeline (`resolve_field_pattern_case`/`desugar_struct_literals`/`permute_binders` in core_check.rs, and their lang/typecheck mirrors) unchanged, no other file needed to change. Tests: 7 Rust integration tests (core/tests/field_access_integration_test.rs) covering single/chained access, field-order correctness, plain `type`, shadowing, module-path regression, and both error paths; 3 unit tests in lower_core.rs; 3 self-hosted tests in lang/module.mo. Also corrects AGENTS.md's stale "dot syntax doesn't work for field access" note (which also described a since-removed legacy "method call" desugaring) to describe current behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>