Crystal: Formatter: Trailing comma bug

Created on 22 Mar 2018  路  3Comments  路  Source: crystal-lang/crystal

Found here: shards/test/integration/update_test.cr

With 0.24.2:

$ crystal tool format ./test/integration/update_test.cr --check
Error: couldn't format './test/integration/update_test.cr', please report a bug...

Reproducible code:

def with_shard(metadata, &block)
  yield
end

with_shard("hello", ) do
  puts "world"
end

With master (2d93603d4):

$ ./bin/crystal tool format a.cr --check
Using compiled compiler at `.build/crystal'
Error: couldn't format 'a.cr', please report a bug...
bug topicformatter

Most helpful comment

Just to clarify: A comma after a block argument (foo(&block, )) neither compiles nor formats because it is a syntax error. And that sound right.

All 3 comments

Is it a formatter bug, should example above compile in the first place?

It compiles, and I think that is okay. It doesn't do any harm and array and hash literals accept trailing commas as well.
But the formatter should probably remove it (and obviously not fall over it).

Just to clarify: A comma after a block argument (foo(&block, )) neither compiles nor formats because it is a syntax error. And that sound right.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

farleyknight picture farleyknight  路  64Comments

akzhan picture akzhan  路  67Comments

ezrast picture ezrast  路  84Comments

malte-v picture malte-v  路  77Comments

chocolateboy picture chocolateboy  路  87Comments