Skip to content

Fix issue with GTS transform with backtick comments#227

Merged
NullVoxPopuli merged 5 commits into
mainfrom
copilot/add-failing-test-for-parser
Jul 2, 2026
Merged

Fix issue with GTS transform with backtick comments#227
NullVoxPopuli merged 5 commits into
mainfrom
copilot/add-failing-test-for-parser

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

transformForLint throws bad transform for a valid GTS class template containing Glimmer comments with backtick-delimited text, even though the underlying parser accepts the template.

  • Regression coverage
    • Adds a focused transformForLint test using the reported template shape.
    • Captures the failing lint-transform path rather than the direct parser path.
export default class MyComponent extends Component {
  <template>
    {{!  `asd` `qwe` `zxc` `undefined` `asd` }}
    {{! `@foo` }}
  </template>
}

Copilot AI linked an issue Jul 2, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add failing test for parser breaking on specific template Add regression test for GTS transform with backtick comments Jul 2, 2026
Copilot AI requested a review from NullVoxPopuli July 2, 2026 00:43
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🏎️ Benchmark Comparison

Benchmark Control (p50) Experiment (p50) Δ
🟢 gts small 1196.29 ms 1138.91 ms -4.8%
gts medium 2151.48 ms 2189.24 ms +1.8%
🟠 gts large 1011.05 ms 1054.96 ms +4.3%
gjs small 962.86 ms 970.80 ms +0.8%
🟠 gjs medium 1795.24 ms 1865.14 ms +3.9%
gjs large 830.68 ms 828.65 ms -0.2%
🟠 hbs small 162.82 ms 166.68 ms +2.4%
🟠 hbs medium 936.42 ms 981.31 ms +4.8%
🔴 hbs large 950.80 ms 1009.71 ms +6.2%

🟢 faster · 🔴 slower · 🟠 slightly slower · ⚪ within 2%

Full mitata output
clk: ~3.11 GHz
cpu: AMD EPYC 7763 64-Core Processor
runtime: node 24.18.0 (x64-linux)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
gts small (control)             1.22 s/iter    1.27 s             █       █
                          (1.04 s … 1.47 s)    1.34 s ▅    ▅ ▅▅▅ ▅█   ▅   █
                    (148.62 mb … 156.84 mb) 151.44 mb █▁▁▁▁█▁███▁██▁▁▁█▁▁▁█

gts small (experiment)          1.18 s/iter    1.20 s     █       █        
                          (1.03 s … 1.36 s)    1.31 s ▅   █ ▅▅▅  ▅█     ▅ ▅
                    (138.73 mb … 192.98 mb) 152.35 mb █▁▁▁█▁███▁▁██▁▁▁▁▁█▁█

                             ┌                                            ┐
                              ╷               ┌──────────┬──────┐         ╷
         gts small (control)  ├───────────────┤          │      ├─────────┤
                              ╵               └──────────┴──────┘         ╵
                             ╷       ┌────────────┬───┐               ╷
      gts small (experiment) ├───────┤            │   ├───────────────┤
                             ╵       └────────────┴───┘               ╵
                             └                                            ┘
                             1.03 s              1.18 s              1.34 s

summary
  gts small (experiment)
   1.04x faster than gts small (control)

------------------------------------------- -------------------------------
gts medium (control)            2.19 s/iter    2.29 s           █          
                          (2.00 s … 2.51 s)    2.31 s           █         █
                    (331.76 mb … 351.37 mb) 338.41 mb █▁▁█▁▁███▁█▁▁▁▁▁▁▁█▁█

gts medium (experiment)         2.21 s/iter    2.25 s █    ██ ██ █ ██ ██  █
                          (2.04 s … 2.51 s)    2.31 s █    ██ ██ █ ██ ██  █
                    (325.51 mb … 337.49 mb) 329.55 mb █▁▁▁▁██▁██▁█▁██▁██▁▁█

                             ┌                                            ┐
                             ╷            ┌─────────────┬──────────────┐  ╷
        gts medium (control) ├────────────┤             │              ├──┤
                             ╵            └─────────────┴──────────────┘  ╵
                                  ╷           ┌────────────┬─────┐       ╷
     gts medium (experiment)      ├───────────┤            │     ├───────┤
                                  ╵           └────────────┴─────┘       ╵
                             └                                            ┘
                             2.00 s              2.16 s              2.31 s

summary
  gts medium (control)
   1.01x faster than gts medium (experiment)

------------------------------------------- -------------------------------
gts large (control)             1.05 s/iter    1.08 s    █                 
                       (957.11 ms … 1.35 s)    1.11 s ▅▅ █▅  ▅  ▅    ▅▅ ▅ ▅
                    (133.24 mb … 184.84 mb) 156.71 mb ██▁██▁▁█▁▁█▁▁▁▁██▁█▁█

gts large (experiment)          1.09 s/iter    1.12 s   █              █   
                       (992.49 ms … 1.35 s)    1.14 s ▅▅█  ▅  ▅   ▅  ▅ █  ▅
                    (123.17 mb … 180.05 mb) 148.46 mb ███▁▁█▁▁█▁▁▁█▁▁█▁█▁▁█

                             ┌                                            ┐
                             ╷    ┌─────────────────┬──────┐      ╷
         gts large (control) ├────┤                 │      ├──────┤
                             ╵    └─────────────────┴──────┘      ╵
                                      ╷  ┌──────────────────┬────────┐    ╷
      gts large (experiment)          ├──┤                  │        ├────┤
                                      ╵  └──────────────────┴────────┘    ╵
                             └                                            ┘
                             957.11 ms            1.05 s             1.14 s

summary
  gts large (control)
   1.03x faster than gts large (experiment)

------------------------------------------- -------------------------------
gjs small (control)             1.00 s/iter    1.03 s              █       
                       (875.08 ms … 1.23 s)    1.12 s     █        █       
                    (111.96 mb … 155.57 mb) 138.83 mb █▁▁▁████▁▁▁▁▁█▁▁█▁▁▁█

gjs small (experiment)          1.01 s/iter    1.06 s      █               
                       (887.16 ms … 1.22 s)    1.09 s ▅  ▅ █▅ ▅    ▅ ▅ ▅▅ ▅
                    (108.07 mb … 152.27 mb) 140.32 mb █▁▁█▁██▁█▁▁▁▁█▁█▁██▁█

                             ┌                                            ┐
                             ╷        ┌──────────────┬─────┐              ╷
         gjs small (control) ├────────┤              │     ├──────────────┤
                             ╵        └──────────────┴─────┘              ╵
                               ╷        ┌─────────────┬─────────┐     ╷
      gjs small (experiment)   ├────────┤             │         ├─────┤
                               ╵        └─────────────┴─────────┘     ╵
                             └                                            ┘
                             875.08 ms           995.20 ms           1.12 s

summary
  gjs small (control)
   1x faster than gjs small (experiment)

------------------------------------------- -------------------------------
gjs medium (control)            1.85 s/iter    1.91 s      ██             █
                          (1.73 s … 2.16 s)    1.95 s ▅ ▅  ██  ▅ ▅    ▅   █
                    (270.48 mb … 279.05 mb) 273.12 mb █▁█▁▁██▁▁█▁█▁▁▁▁█▁▁▁█

gjs medium (experiment)         1.88 s/iter    1.89 s █   █     █          
                          (1.76 s … 2.16 s)    2.00 s █  ▅█    ▅█▅▅       ▅
                    (256.25 mb … 309.90 mb) 281.11 mb █▁▁██▁▁▁▁████▁▁▁▁▁▁▁█

                             ┌                                            ┐
                             ╷        ┌───────────┬────────┐      ╷
        gjs medium (control) ├────────┤           │        ├──────┤
                             ╵        └───────────┴────────┘      ╵
                                   ╷     ┌────────────┬──┐                ╷
     gjs medium (experiment)       ├─────┤            │  ├────────────────┤
                                   ╵     └────────────┴──┘                ╵
                             └                                            ┘
                             1.73 s              1.86 s              2.00 s

summary
  gjs medium (control)
   1.01x faster than gjs medium (experiment)

------------------------------------------- -------------------------------
gjs large (control)          868.07 ms/iter 894.11 ms  █             █     
                       (784.23 ms … 1.11 s) 929.98 ms ▅█ ▅▅ ▅   ▅    █  ▅ ▅
                    (109.68 mb … 160.36 mb) 130.94 mb ██▁██▁█▁▁▁█▁▁▁▁█▁▁█▁█

gjs large (experiment)       876.83 ms/iter 911.79 ms    █                 
                       (792.55 ms … 1.11 s) 953.82 ms ▅▅▅█▅  ▅      ▅▅▅   ▅
                    ( 99.37 mb … 151.94 mb) 135.47 mb █████▁▁█▁▁▁▁▁▁███▁▁▁█

                             ┌                                            ┐
                             ╷ ┌───────────────────┬──────┐         ╷
         gjs large (control) ├─┤                   │      ├─────────┤
                             ╵ └───────────────────┴──────┘         ╵
                               ╷    ┌─────────────────┬────────┐          ╷
      gjs large (experiment)   ├────┤                 │        ├──────────┤
                               ╵    └─────────────────┴────────┘          ╵
                             └                                            ┘
                             784.23 ms         869.02 ms          953.82 ms

summary
  gjs large (control)
   1.01x faster than gjs large (experiment)

------------------------------------------- -------------------------------
hbs small (control)          176.01 ms/iter 182.74 ms    █                 
                    (148.97 ms … 276.90 ms) 191.35 ms ▅▅ █ ▅ ▅ ▅  ▅   ▅ ▅ ▅
                    ( 26.06 mb …  67.87 mb)  30.80 mb ██▁█▁█▁█▁█▁▁█▁▁▁█▁█▁█

hbs small (experiment)       176.22 ms/iter 183.15 ms            █         
                    (128.84 ms … 275.22 ms) 199.29 ms ▅     ▅ ▅▅▅█  ▅▅▅   ▅
                    ( 24.46 mb …  67.36 mb)  32.60 mb █▁▁▁▁▁█▁████▁▁███▁▁▁█

                             ┌                                            ┐
                                          ╷   ┌────────────┬───┐     ╷
         hbs small (control)              ├───┤            │   ├─────┤
                                          ╵   └────────────┴───┘     ╵
                             ╷                 ┌───────────┬────┐         ╷
      hbs small (experiment) ├─────────────────┤           │    ├─────────┤
                             ╵                 └───────────┴────┘         ╵
                             └                                            ┘
                             128.84 ms         164.07 ms          199.29 ms

summary
  hbs small (control)
   1x faster than hbs small (experiment)

------------------------------------------- -------------------------------
hbs medium (control)         960.95 ms/iter 981.89 ms █        ██          
                       (883.72 ms … 1.14 s)    1.08 s █▅▅ ▅▅   ██         ▅
                    (168.35 mb … 219.54 mb) 200.76 mb ███▁██▁▁▁██▁▁▁▁▁▁▁▁▁█

hbs medium (experiment)         1.01 s/iter    1.02 s █  █                 
                       (938.83 ms … 1.18 s)    1.09 s █  █▅ ▅ ▅▅ ▅  ▅     ▅
                    (144.91 mb … 199.41 mb) 185.47 mb █▁▁██▁█▁██▁█▁▁█▁▁▁▁▁█

                             ┌                                            ┐
                             ╷┌───────────────┬────┐                   ╷
        hbs medium (control) ├┤               │    ├───────────────────┤
                             ╵└───────────────┴────┘                   ╵
                                         ╷   ┌──────────┬──┐              ╷
     hbs medium (experiment)             ├───┤          │  ├──────────────┤
                                         ╵   └──────────┴──┘              ╵
                             └                                            ┘
                             883.72 ms           986.00 ms           1.09 s

summary
  hbs medium (control)
   1.05x faster than hbs medium (experiment)

------------------------------------------- -------------------------------
hbs large (control)          996.08 ms/iter    1.03 s   █                  
                       (928.96 ms … 1.17 s)    1.06 s   ██                 
                    (152.35 mb … 156.63 mb) 153.82 mb █▁██▁▁▁▁▁▁█▁█▁▁▁██▁▁█

hbs large (experiment)          1.03 s/iter    1.06 s ██ █  ██ █   █ █ ██ █
                       (938.54 ms … 1.20 s)    1.09 s ██ █  ██ █   █ █ ██ █
                    (129.49 mb … 188.84 mb) 158.32 mb ██▁█▁▁██▁█▁▁▁█▁█▁██▁█

                             ┌                                            ┐
                             ╷   ┌──────────────┬─────────┐      ╷
         hbs large (control) ├───┤              │         ├──────┤
                             ╵   └──────────────┴─────────┘      ╵
                                ╷      ┌─────────────────┬─────────┐      ╷
      hbs large (experiment)    ├──────┤                 │         ├──────┤
                                ╵      └─────────────────┴─────────┘      ╵
                             └                                            ┘
                             928.96 ms            1.01 s             1.09 s

summary
  hbs large (control)
   1.03x faster than hbs large (experiment)

@NullVoxPopuli

Copy link
Copy Markdown
Member

@copilot good, now find out where the fix should be, or if we need to improve the error coming from content_tag -- or if we need to open a failing test PR on content_tag

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot good, now find out where the fix should be, or if we need to improve the error coming from content_tag -- or if we need to open a failing test PR on content_tag

Found this in our transformForLint, not content-tag: content-tag returns the expected template range/content, but our placeholder escaped backticks inside comments, increasing the replacement length and tripping bad transform. Fixed in 1e7c572 by masking template contents for the lint placeholder while preserving output length/line breaks.

Comment thread src/parser/transforms.js Outdated
let jsCode = code;
for (const tplInfo of [...result].reverse()) {
const content = tplInfo.contents.replace(/`/g, '\\`').replace(/\$/g, '\\$');
const content = tplInfo.contents.replace(/[^\r\n]/g, ' ');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why is this the fix? what are we replacing (windows line endings)(?) with?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is in the lint-only placeholder path: we don't need template contents there, only stable offsets/lines for TS/ESLint. The replacement now masks every non-line-ending character in the template body with a space, while preserving \r and \n (including CRLF) unchanged. That prevents comment backticks/${...} from changing the JS template literal placeholder length or syntax. Clarified this in f864056.

@NullVoxPopuli

This comment was marked as outdated.

@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review July 2, 2026 03:23
@NullVoxPopuli NullVoxPopuli merged commit 8dc030b into main Jul 2, 2026
74 of 75 checks passed
@NullVoxPopuli NullVoxPopuli deleted the copilot/add-failing-test-for-parser branch July 2, 2026 20:50
@github-actions github-actions Bot mentioned this pull request Jul 2, 2026
@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Jul 2, 2026
@NullVoxPopuli NullVoxPopuli changed the title Add regression test for GTS transform with backtick comments Fix issue with GTS transform with backtick comments Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser breaks on a specific template

2 participants