[CLI] Is the $-joined path shown for variables inside imported modules intended? #26

Closed
opened 2026-08-31 21:45:16 +02:00 by Nopitch · 1 comment

Version: @gram-lang/cli 1.2.1 (current npm latest), on macOS.

Summary

When a recipe imports a module, any intermediate variable referenced inside that module renders as a $-joined path rather than its name. The depth of the import chain determines how many segments appear.

I could not find anything in the reference describing how these should display, so this may well be deliberate disambiguation rather than a defect — flagging it as a question. What made me doubt is that $ is not a documented syntax character anywhere, which made it read like an internal identifier surfacing in human-facing output.

Reproduction

Three files in one project. a.gram:

---
title: A
---

## Press

Press the @tofu{200g}. ->&pressed

## Marinate ->&marinated

Slice the &pressed{} and coat it.

b.gram:

---
title: B
---

@use "./a.gram" as &marinated ~{-1d}

## Grill ->&grilled

Pan-fry the &marinated{}.

c.gram:

---
title: C
---

@use "./b.gram" as &tofu

## Assemble

Add the &tofu{}.

gram check reports all three valid. gram view c.gram --skip-db --no-pager renders:

─── Press ────────────────────────────────
   1.   Press the tofu.

─── Marinate ─────────────────────────────
   2.   Slice the tofu$marinated$pressed and coat it.

─── Grill ────────────────────────────────
   3.   Pan-fry the tofu$marinated.

─── Assemble ─────────────────────────────
   4.   Add the tofu.

Actual vs expected

Step Rendered Expected
innermost, 2 levels down tofu$marinated$pressed pressed
middle, 1 level down tofu$marinated marinated
top level tofu tofu — correct

Only the reference written in the importing file renders correctly. Every reference that lives inside an imported module shows its path.

Note

Everything else about module composition works well: gram check passes, the retro-planning offset on the @use propagates into the recipe total, and the shopping list consolidates ingredients shared across modules correctly — an ingredient used once in each of two modules aggregates into a single line with the summed quantity, as documented. It is only the rendered label, which — going by the pipeline in CONTRIBUTING — suggests packages/renderer rather than packages/modules, since resolution itself clearly works.


Drafted with AI assistance, verified by hand: every reproduction above was run locally against 1.2.1 and its output pasted verbatim.

**Version:** `@gram-lang/cli` 1.2.1 (current npm `latest`), on macOS. ## Summary When a recipe imports a module, any intermediate variable referenced *inside* that module renders as a `$`-joined path rather than its name. The depth of the import chain determines how many segments appear. I could not find anything in the reference describing how these should display, so this may well be deliberate disambiguation rather than a defect — flagging it as a question. What made me doubt is that `$` is not a documented syntax character anywhere, which made it read like an internal identifier surfacing in human-facing output. ## Reproduction Three files in one project. `a.gram`: ```gram --- title: A --- ## Press Press the @tofu{200g}. ->&pressed ## Marinate ->&marinated Slice the &pressed{} and coat it. ``` `b.gram`: ```gram --- title: B --- @use "./a.gram" as &marinated ~{-1d} ## Grill ->&grilled Pan-fry the &marinated{}. ``` `c.gram`: ```gram --- title: C --- @use "./b.gram" as &tofu ## Assemble Add the &tofu{}. ``` `gram check` reports all three valid. `gram view c.gram --skip-db --no-pager` renders: ``` ─── Press ──────────────────────────────── 1. Press the tofu. ─── Marinate ───────────────────────────── 2. Slice the tofu$marinated$pressed and coat it. ─── Grill ──────────────────────────────── 3. Pan-fry the tofu$marinated. ─── Assemble ───────────────────────────── 4. Add the tofu. ``` ## Actual vs expected | Step | Rendered | Expected | |---|---|---| | innermost, 2 levels down | `tofu$marinated$pressed` | `pressed` | | middle, 1 level down | `tofu$marinated` | `marinated` | | top level | `tofu` | `tofu` — correct | Only the reference written in the importing file renders correctly. Every reference that lives inside an imported module shows its path. ## Note Everything else about module composition works well: `gram check` passes, the retro-planning offset on the `@use` propagates into the recipe total, and the shopping list consolidates ingredients shared across modules correctly — an ingredient used once in each of two modules aggregates into a single line with the summed quantity, as documented. It is only the rendered label, which — going by the pipeline in CONTRIBUTING — suggests `packages/renderer` rather than `packages/modules`, since resolution itself clearly works. --- *Drafted with AI assistance, verified by hand: every reproduction above was run locally against 1.2.1 and its output pasted verbatim.*
abiwab self-assigned this 2026-09-28 22:15:18 +02:00
Owner

Again, thanks for your report, and no, that wasn't intended. The $ path is an internal name we use to keep modules from clashing, and it shouldn't have shown up in the output. It's fixed in #39, so labels now show the name you wrote (pressed, marinated). It'll ship in the next release.

Again, thanks for your report, and no, that wasn't intended. The $ path is an internal name we use to keep modules from clashing, and it shouldn't have shown up in the output. It's fixed in #39, so labels now show the name you wrote (pressed, marinated). It'll ship in the next release.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gram-lang/gram#26
No description provided.