Skip to content

Syntax error for a statement with multiple lines #20

@piroor

Description

@piroor

For readability I sometimes want to write a code like:

assert do
  # folded because it is too long for one line
  foo.bar?(a: aaaaaaaaaaaaaaaaaaaaaa, 
           b: bbbbbbbbbbbbbbbbbbbbbb,
           c: ccccccccccccccccccccccccc)
end

However power_assert reports a syntax error for such cases, because it just parses codes per lines. Thus, I hope that this "issue" to be fixed in these two steps:

  1. Just add a note for the known limitation to the README.md.
  2. Add support for such cases, and remove the note for the fixed problem.

How about that?


うまく伝えられているか自信がないので日本語でも書きます。
冒頭の例のように、1行が長くなりすぎる時に読みやすさのため途中に改行を入れるということはよくあると思います。しかしながら、現在のpower_assertは行単位でコードをパースしているため、このようなコードがあると文法エラーになってしまうという問題があります。そこで、以下の2段階で解決していくのはどうかと考えています。

  1. まずREADME.mdに、既知の制限事項として注意書きを追加する。
  2. 複数行に渡る文への対応を進め、作業が完了した時点でその注意書きを削除する。

2は実現可能なのかどうかまだ判断がつかないため、最悪の場合1だけに留まる可能性もあると考えておりますが、何も注意書きがないよりは、ユーザーがいざ同じ問題に遭遇した時に戸惑わずに済むのではないかと思います。
いかがでしょうか?
(この方法で進めてよいということであれば、こちらで作業しPRするつもりでおります。)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions