diff --git a/CHANGELOG.md b/CHANGELOG.md index 30a38ca..f12b677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,17 @@ Versions follow [Semantic Versioning](https://semver.org/) — minor bump per su BROWSE/REPLACE enforcement, field-bound forms, two demo apps, and the GUI wizards all now agree on one constraint, declared once, on the column. +### Fixed +- A memory-variable `@ SAY GET` no longer shows blank when the variable already holds a + value. Field-binding (#59) rewrote the non-field fallback path to hardcode an empty + prefill instead of reading the variable's current value, silently breaking every demo + form that pre-fills a default via `STORE`: `overtime.prg`'s Week Monday date (Open/Prep + Week, Recalculate Week) and leave date (Register Leave Taken), `INVENTORY.prg`'s stock/ + reorder/price/quantity defaults (Add Product, Stock In, Stock Out), and `crm.prg`'s deal + value default (Add Deal). Found by exercising the running app, not by the test suite — + every existing test for this path used a variable with no prior value, where an empty + prefill happens to be correct either way. + ## [1.2.0] — 2026-07-09 — TIME columns, WEEK()/DATEADD(), BROWSE cell validation, Overtime demo ### Added diff --git a/src/interpreter/Executor.ts b/src/interpreter/Executor.ts index f15283a..a261fb3 100644 --- a/src/interpreter/Executor.ts +++ b/src/interpreter/Executor.ts @@ -588,7 +588,10 @@ export class Executor implements IndexCommandsHost { return { output: out }; } } - this.pendingForm.push({ row, col, label: text, varName, target: { kind: 'var' }, value: '' }); + this.pendingForm.push({ + row, col, label: text, varName, target: { kind: 'var' }, + value: String(this.vars.get(varName) ?? ''), + }); return { output: out }; } diff --git a/tests/FormFieldBinding.test.ts b/tests/FormFieldBinding.test.ts index dfdea37..f186e3e 100644 --- a/tests/FormFieldBinding.test.ts +++ b/tests/FormFieldBinding.test.ts @@ -77,6 +77,16 @@ describe('field-bound @ SAY GET', () => { expect(form.fields[0].value).toBe(''); }); + it('a variable GET prefills from the variable\'s current value, not blank', async () => { + const { session, sent, run } = await setup(); + await run('APPEND RECORD'); + await run('STORE "2026-07-06" TO M_WEEK'); + await runBlock(session, sent, '@ 4, 5 SAY "Week: " GET M_WEEK\nREAD'); + const form = sent.find(m => m.type === 'form-open') as any; + expect(form.fields[0].target.kind).toBe('var'); + expect(form.fields[0].value).toBe('2026-07-06'); + }); + it('is a variable GET when no table is in use', async () => { const sent: ServerMessage[] = []; const session = new Session((m) => sent.push(m));