Skip to content

Update is_binaryop_nestable to retain the same meaning on JuliaSyntax@1#1193

Closed
penelopeysm wants to merge 1 commit into
masterfrom
blue2
Closed

Update is_binaryop_nestable to retain the same meaning on JuliaSyntax@1#1193
penelopeysm wants to merge 1 commit into
masterfrom
blue2

Conversation

@penelopeysm

@penelopeysm penelopeysm commented Jun 26, 2026

Copy link
Copy Markdown
Member

Closes #1013

f() = ... used to return true for is_assignment(cst) with JuliaSyntax@0.4

 julia> parseall(GreenNode, s)
       1:153    │[toplevel]
       1:153    │  [=]
       1:103    │    [::]
       1:97     │      [call]
       1:17     │        Identifier       ✔
      18:18     │        (
      19:70     │        [::]
      19:20     │          Identifier     ✔
      21:22::
      23:70     │          [curly]
      23:27     │            Identifier   ✔
      28:28     │            {
      29:46     │            Identifier   ✔
      47:47     │            ,
      48:69     │            Identifier   ✔
      70:70     │            }
      71:71     │        ,
      72:72     │        Whitespace
      73:96     │        [::]
      73:79     │          Identifier     ✔
      80:81::
      82:96     │          Identifier     ✔
      97:97     │        )
      98:99::
     100:103    │      Identifier         ✔
     104:104    │    Whitespace
     105:105=
     106:106    │    Whitespace
     107:153    │    [call]
     107:123    │      Identifier         ✔
     124:124    │      (
     125:126    │      Identifier         ✔
     127:127    │      ,
     128:128    │      Whitespace
     129:135    │      Identifier         ✔
     136:136    │      ,
     137:137    │      Whitespace
     138:152    │      [.]
     138:144    │        Identifier       ✔
     145:145    │        .
     146:152    │        [quote]
     146:152    │          Identifier
     153:153    │      )

But it's different in JuliaSyntax v1

     1:154    │[toplevel]
     1:153    │  [function]
     1:103    │    [::]
     1:97     │      [call]
     1:17     │        Identifier       ✔
    18:18     │        (
    19:70     │        [::]
    19:20     │          Identifier     ✔
    21:22::
    23:70     │          [curly]
    23:27     │            Identifier   ✔
    28:28     │            {
    29:46     │            Identifier   ✔
    47:47     │            ,
    48:69     │            Identifier   ✔
    70:70     │            }
    71:71     │        ,
    72:72     │        Whitespace
    73:96     │        [::]
    73:79     │          Identifier     ✔
    80:81::
    82:96     │          Identifier     ✔
    97:97     │        )
    98:99::
   100:103    │      Identifier         ✔
   104:104    │    Whitespace
   105:105=
   106:106    │    Whitespace
   107:153    │    [call]
   107:123    │      Identifier         ✔
   124:124    │      (
   125:126    │      Identifier         ✔
   127:127    │      ,
   128:128    │      Whitespace
   129:135    │      Identifier         ✔
   136:136    │      ,
   137:137    │      Whitespace
   138:152    │      [.]
   138:144    │        Identifier       ✔
   145:145    │        .
   146:152    │        Identifier       ✔
   153:153    │      )
   154:154    │  NewlineWs

which causes is_assignment() to return false. The solution is to add defines_function(cst) to catch this case.

@penelopeysm penelopeysm changed the title Update is_binaryop_nestable to be compatible with JuliaSyntax@1 Update is_binaryop_nestable to retain the same meaning on JuliaSyntax@1 Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@penelopeysm

Copy link
Copy Markdown
Member Author

This broke #911

[6](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/actions/runs/28249996807/job/83698800525?pr=1193#step:6:149)
Formatting output did not match expected value.

Expected:
@testset begin
    DynamicPPL.assume(
        ::Random.AbstractRNG, ::DynamicPPL.Sampler{MyEmptyAlg}, dist, vn, vi
    ) = DynamicPPL.assume(dist, vn, vi)
end


Got:
@testset begin
    DynamicPPL.assume(::Random.AbstractRNG, ::DynamicPPL.Sampler{MyEmptyAlg}, dist, vn, vi) = DynamicPPL.assume(
        dist, vn, vi
    )
end


Repro:
s = "@testset begin\n    DynamicPPL.assume(::Random.AbstractRNG, ::DynamicPPL.Sampler{MyEmptyAlg}, dist, vn, vi) = DynamicPPL.assume(\n            dist, vn, vi\n        )\nend\n"
format_text(s, BlueStyle())
911: Test Failed at /home/runner/work/JuliaFormatter.jl/JuliaFormatter.jl/src/internal/utils.jl:211

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.

Formatting output changed in minor version increment

1 participant