Skip to content

Idempotency Failure: Trailing comments #936

Description

@nicholasdower

Originally reported in #915

Commit: 95210d7

Input

→ View on rubyfmt.run

a.
  b # c

a = %w[
  b
] << "c"  # d

a if
  b.c # d

def a
  (
    [:b] # c
  ).map {}
end

Output

→ View on rubyfmt.run

a# c
.b

a = # d
%w[
  b
] <<
  "c"

if # d
b.c
  a
end

def a
    # c
([:b])
    .map { }
end

Second Output

# c
a
  .b

# d
a = %w[
  b
] <<
  "c"

# d
if b.c
  a
end

def a
  # c
  ([:b])
    .map { }
end

Expected behavior

The output should be stable.

Found in: coderay 1.1.3 (lib/coderay/scanners/java.rb)
Found in: builder 3.3.0 (lib/builder/xmlbase.rb)
Found in: json 2.19.8 (lib/json/ext/generator/state.rb)
Found in: rbs 4.0.2 (lib/rbs/prototype/runtime/value_object_generator.rb)
Found in: pdf-reader 2.15.1 (lib/pdf/reader/font_descriptor.rb)
Found in: parslet 2.0.0 (lib/parslet/atoms/can_flatten.rb)
Found in: whenever 1.1.2 (lib/whenever/command_line.rb)
Found in: discourse-discourse main (script/import_scripts/discuz_x.rb)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions