Title: Heredoc's body range is wrong when multiple heredocs used · Issue #93 · lib-ruby-parser/lib-ruby-parser · GitHub
Open Graph Title: Heredoc's body range is wrong when multiple heredocs used · Issue #93 · lib-ruby-parser/lib-ruby-parser
X Title: Heredoc's body range is wrong when multiple heredocs used · Issue #93 · lib-ruby-parser/lib-ruby-parser
Description: Hi, thank you for so useful library. Today I found a problem about a heredoc. Its body location range seems wrong when multiple heredocs are used. Example Ruby code that reproduces the problem: puts(<<~H1, <<~H2) 1 H1 2 H2 You can see th...
Open Graph Description: Hi, thank you for so useful library. Today I found a problem about a heredoc. Its body location range seems wrong when multiple heredocs are used. Example Ruby code that reproduces the problem: put...
X Description: Hi, thank you for so useful library. Today I found a problem about a heredoc. Its body location range seems wrong when multiple heredocs are used. Example Ruby code that reproduces the problem: put...
Opengraph URL: https://github.com/lib-ruby-parser/lib-ruby-parser/issues/93
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Heredoc's body range is wrong when multiple heredocs used","articleBody":"Hi, thank you for so useful library.\r\nToday I found a problem about a heredoc. Its body location range seems wrong when multiple heredocs are used.\r\n\r\nExample Ruby code that reproduces the problem:\r\n\r\n```ruby\r\nputs(\u003c\u003c~H1, \u003c\u003c~H2)\r\n1\r\nH1\r\n2\r\nH2\r\n```\r\n\r\nYou can see the problem by this Rust code that parse the above Ruby code and prints the AST.\r\n\r\n```rust\r\nfn main() {\r\n let src = \"puts(\u003c\u003c~H1, \u003c\u003c~H2)\r\n1\r\nH1\r\n2\r\nH2\";\r\n let parser = lib_ruby_parser::Parser::new(src, Default::default());\r\n let result = parser.do_parse();\r\n dbg!(result.ast);\r\n}\r\n```\r\n\r\nThere are two `Heredoc` nodes in the AST. However, the second body range includes the first body range.\r\n\r\n- `H1` ... `heredoc_body_l: 19...21`\r\n- `H2` ... `heredoc_body_l: 19...26`\r\n\r\nWhole print result:\r\n\r\n```\r\n[src/main.rs:9] result.ast = Some(\r\n Send(\r\n Send {\r\n recv: None,\r\n method_name: \"puts\",\r\n args: [\r\n Heredoc(\r\n Heredoc {\r\n parts: [\r\n Str(\r\n Str {\r\n value: Bytes {\r\n raw: [\r\n 49,\r\n 10,\r\n ],\r\n },\r\n begin_l: None,\r\n end_l: None,\r\n expression_l: 19...21,\r\n },\r\n ),\r\n ],\r\n heredoc_body_l: 19...21,\r\n heredoc_end_l: 21...23,\r\n expression_l: 5...10,\r\n },\r\n ),\r\n Heredoc(\r\n Heredoc {\r\n parts: [\r\n Str(\r\n Str {\r\n value: Bytes {\r\n raw: [\r\n 50,\r\n 10,\r\n ],\r\n },\r\n begin_l: None,\r\n end_l: None,\r\n expression_l: 19...26,\r\n },\r\n ),\r\n ],\r\n heredoc_body_l: 19...26,\r\n heredoc_end_l: 26...28,\r\n expression_l: 12...17,\r\n },\r\n ),\r\n ],\r\n dot_l: None,\r\n selector_l: Some(\r\n 0...4,\r\n ),\r\n begin_l: Some(\r\n 4...5,\r\n ),\r\n end_l: Some(\r\n 17...18,\r\n ),\r\n operator_l: None,\r\n expression_l: 0...18,\r\n },\r\n ),\r\n)\r\n```","author":{"url":"https://github.com/ryym","@type":"Person","name":"ryym"},"datePublished":"2023-12-17T02:52:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/93/lib-ruby-parser/issues/93"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c84719fd-068f-9c04-0751-b18fe86dc141 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C5D0:18F78E:F4B9A:13B659:69900D61 |
| html-safe-nonce | dc40a26d111c7947049036c68cd627af1a524ad46ae4bfa180d47caf331425e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNUQwOjE4Rjc4RTpGNEI5QToxM0I2NTk6Njk5MDBENjEiLCJ2aXNpdG9yX2lkIjoiMTI4OTc3NjUyODk4MTIzMjk5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5c485632ab9ed1df99a9654a5495da37bc328e2716ca7557752f1eb51c6d3ea9 |
| hovercard-subject-tag | issue:2045031888 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/lib-ruby-parser/lib-ruby-parser/93/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9bee1da95f89f1e19ca97f9586130616ac72b2951ca4f315bf4e32c26aff6542/lib-ruby-parser/lib-ruby-parser/issues/93 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9bee1da95f89f1e19ca97f9586130616ac72b2951ca4f315bf4e32c26aff6542/lib-ruby-parser/lib-ruby-parser/issues/93 |
| og:image:alt | Hi, thank you for so useful library. Today I found a problem about a heredoc. Its body location range seems wrong when multiple heredocs are used. Example Ruby code that reproduces the problem: put... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ryym |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/lib-ruby-parser/lib-ruby-parser git https://github.com/lib-ruby-parser/lib-ruby-parser.git |
| octolytics-dimension-user_id | 71789678 |
| octolytics-dimension-user_login | lib-ruby-parser |
| octolytics-dimension-repository_id | 298071274 |
| octolytics-dimension-repository_nwo | lib-ruby-parser/lib-ruby-parser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 298071274 |
| octolytics-dimension-repository_network_root_nwo | lib-ruby-parser/lib-ruby-parser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width