Skip to content

[port #1055] internal/literals: preserve constant string expression semantics - #7

Open
luantak wants to merge 2 commits into
masterfrom
cursor/maremagnum-pr-1055-literals-constant-selection-2676
Open

[port #1055] internal/literals: preserve constant string expression semantics#7
luantak wants to merge 2 commits into
masterfrom
cursor/maremagnum-pr-1055-literals-constant-selection-2676

Conversation

@luantak

@luantak luantak commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Validity: valid

Correctness fix: rewriting strings under folded constant expressions can break array lengths / keyed indexes, and can leave dead decoders. Selecting only the largest eligible string (and only suppressing children when the parent itself is in range) is the right semantics for -literals.

Upstream

burrowers#1055

Commit layout

Commit 1 is Maremagnum's from burrowers#1055 (author preserved as on the upstream commit: autoprofiler <autoprofiler@local.invalid>); following commit(s) address luantak/mvdan review feedback and are authored by the Cursor/luantak port side.

  • 07eb04f autoprofiler | internal/literals: preserve constant string expression semantics
  • 89e48e2 Cursor Agent | Address review feedback: walk parents via astutil.Apply ancestry

What this ports

  • Skip strings under non-string constant results
  • Select only the largest eligible string expression
  • Parent suppresses child only when parent itself is within configured literal size range

Feedback applied (luantak requested changes)

  1. Removed custom nodeParents map — parents are walked from the astutil.Apply cursor ancestry with clear exit conditions (non-expression ancestor; constant non-string parent; eligible parent string).
  2. Comments in literals.txtar for the exact things that broke before (constant-context array lengths/keyed indexes; oversize concat suppressing an eligible child).

Testing

  • go test -short ./internal/literals/
  • go test -run 'TestScript/literals$' .

Remaining risks

  • Low-medium. Touches literal selection heuristics; covered by extended literals.txtar cases.

Notes for Paul

Ready for your inspection. Not merged.

Open in Web Open in Cursor 

autoprofiler and others added 2 commits August 11, 2026 21:03
luantak: don't invent a custom nodeParents map — find parents via the
astutil cursor walk; make exit conditions clear. Also comment the
exact failures covered in literals.txtar.

Co-authored-by: Paul <luantak@pm.me>
@cursor
cursor Bot force-pushed the cursor/maremagnum-pr-1055-literals-constant-selection-2676 branch from 7dab957 to 89e48e2 Compare August 11, 2026 21:05
@luantak
luantak marked this pull request as ready for review August 12, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants