Skip to content

Printer bug: empty string literal args are dropped #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 4, 2025

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Feb 28, 2025

The printer (in all modes, not just the hacked-on "codemod mode") loses empty string literal arguments:

-<Hello @world="" />
+<Hello @world />

Copy link
Contributor

github-actions bot commented Feb 28, 2025

This PRmain
Dev
583K └─┬ .
169K   ├── runtime
160K   ├── syntax
100K   ├── compiler
 58K   ├── opcode-compiler
 27K   ├── manager
 19K   ├── validator
 11K   ├── program
8.9K   ├── reference
7.2K   ├── destroyable
6.3K   ├── util
4.3K   ├── node
3.4K   ├── global-context
2.5K   ├── wire-format
1.0K   ├── vm
969B   ├── encoder
844B   ├── vm-babel-plugins
606B   └── owner
583K └─┬ .
169K   ├── runtime
160K   ├── syntax
100K   ├── compiler
 58K   ├── opcode-compiler
 27K   ├── manager
 19K   ├── validator
 11K   ├── program
8.9K   ├── reference
7.2K   ├── destroyable
6.3K   ├── util
4.3K   ├── node
3.4K   ├── global-context
2.5K   ├── wire-format
1.0K   ├── vm
969B   ├── encoder
844B   ├── vm-babel-plugins
606B   └── owner
Prod
230K └─┬ .
 70K   ├── syntax
 63K   ├── runtime
 48K   ├── compiler
 18K   ├── opcode-compiler
7.9K   ├── manager
4.8K   ├── program
4.0K   ├── validator
3.6K   ├── reference
2.4K   ├── util
2.1K   ├── node
1.6K   ├── wire-format
1.5K   ├── destroyable
737B   ├── vm
594B   ├── global-context
516B   ├── encoder
469B   ├── vm-babel-plugins
155B   └── owner
230K └─┬ .
 70K   ├── syntax
 63K   ├── runtime
 48K   ├── compiler
 18K   ├── opcode-compiler
7.9K   ├── manager
4.8K   ├── program
4.0K   ├── validator
3.6K   ├── reference
2.4K   ├── util
2.1K   ├── node
1.6K   ├── wire-format
1.5K   ├── destroyable
737B   ├── vm
594B   ├── global-context
516B   ├── encoder
469B   ├── vm-babel-plugins
155B   └── owner

@ef4
Copy link
Contributor Author

ef4 commented Mar 3, 2025

Followup investigation: the existing behavior isn't strictly incorrect, since a missing attribute or argument value is treated as the empty string.

There's not an obvious best thing to do here in all cases.

  1. The printer doesn't currently make any distinction between arguments and attributes. It's not clear that it should, since at the syntax level they behave identically.

  2. If we continue to print @foo="" as @foo, that runs afoul of a default template-lint rule.

  3. But if we go the other direction and normalize attributes to always show the empty string literal, that would change <input disabled > to <input disabled="">, which is also annoying.

To make both those cases do the expected thing, we'd need to make the printer treat attributes and arguments differently. Maybe that's OK? It seems like the least bad near-term option.

Ultimately we would prefer to have a printer designed from the ground up for format preservation, but that would also require changes all the way down through the glimmer parser and handlebars parser, because information gets lost in both those layers.

@ef4
Copy link
Contributor Author

ef4 commented Mar 3, 2025

I'm very confused about how I can have a seemingly-unrelated CI failure here that isn't reproducing on main.

@ef4 ef4 force-pushed the printer-empty-string-literal branch from 92bb6ab to 948a249 Compare March 4, 2025 17:07
@NullVoxPopuli NullVoxPopuli merged commit 542d4f0 into main Mar 4, 2025
10 of 11 checks passed
@NullVoxPopuli NullVoxPopuli deleted the printer-empty-string-literal branch March 4, 2025 17:33
This was referenced Mar 4, 2025
git-online-helper bot added a commit to patricklx/glimmer-vm that referenced this pull request May 13, 2025
Update lockfile

x

ope

Merge pull request glimmerjs#1726 from glimmerjs/put-prettier-testing-in-the-smoke-tests-project

Move prettier tests to the smoke-tests project

Update release-plan

Don't forget repo meta update

Printer bug: empty string literal args are dropped

proposed fix

lint:fix

Merge pull request glimmerjs#1727 from glimmerjs/update-release-plan

Update release-plan

Merge pull request glimmerjs#1722 from glimmerjs/printer-empty-string-literal

Printer bug: empty string literal args are dropped

Set node-version to 22

Merge pull request glimmerjs#1728 from glimmerjs/set-node-version-to-22

Set node-version to 22 in plan-release/publish

Prepare Release  using 'release-plan'

Merge pull request glimmerjs#1715 from glimmerjs/release-preview

Prepare Release

Revert "Prepare Release"

Merge pull request glimmerjs#1729 from glimmerjs/revert-1715-release-preview

Revert "Prepare Release"

Go back to using configs from before glimmerjs#1727

Merge pull request glimmerjs#1730 from glimmerjs/fix-release-plan

fix release-plan

Prepare Release  using 'release-plan'

Merge pull request glimmerjs#1731 from glimmerjs/release-preview

Prepare Release

Fix bench post-install

ignore-workspace -> ignore-workspace-root-check

Force CI=false for bench

Update bench-packages.mts

Use postinstall script to opt out of postinstall

+x

bah

Merge pull request glimmerjs#1732 from glimmerjs/fix-post-install

Fix bench post-install

Restore {{debugger}} behavior

Merge pull request glimmerjs#1734 from glimmerjs/restore-debugger

Restore {{debugger}} behavior

Prepare Release  using 'release-plan'

Manually update the release-preview to force @glimmer/runtime to release

Add pkgJSONPath

Add constraints array (empty)

Add entry to constraints arary

Add impact

Merge pull request glimmerjs#1733 from glimmerjs/release-preview

Prepare Release

Force release

Merge pull request glimmerjs#1735 from glimmerjs/force-release

Force release

pnpm repo:update:metadata

Merge pull request glimmerjs#1736 from glimmerjs/nvp/update-meta

pnpm repo:update:metadata

Removing editor.rulers

This drives me batty every time I open this repo. I think it's fair to say it falls into opinionated IDE settings that can stay in a personal config instead of the repo.

Merge pull request glimmerjs#1738 from glimmerjs/editor-rulers

Removing editor.rulers

Re-add package.json#types for tsconfig's moduleResolution=node10

Merge pull request glimmerjs#1741 from glimmerjs/add-back-types-for-moduleResolution=node10

Re-add support for tsconfig's moduleResolution=node10

Prepare Release  using 'release-plan'

Merge pull request glimmerjs#1737 from glimmerjs/release-preview

Prepare Release

Upgrade handlebars parser

Upgrade to nppm 10.6.5

Merge pull request glimmerjs#1743 from glimmerjs/upgrade-handlebars-parser

Upgrade handlebars parser

Merge pull request glimmerjs#1744 from glimmerjs/nvp/update-pnpm

Upgrade to pnpm 10.6.5

test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants