Skip to content

Warning/error messages mismatching #2852

@andrykonchin

Description

@andrykonchin

After recent update to the latest Prism we have two new failures in ruby/spec tests suite, related to a bit different warning/exception messages. So wondering if it's a known issue and 100% matching is supposed at all.

#1

  it "warns if there are identical when clauses" do
    -> {
      eval <<~RUBY
        case 1
        when 2
          :foo
        when 2
          :bar
        end
      RUBY
    }.should complain(/warning: duplicated .when' clause with line \d+ is ignored/, verbose: true)
  end

Prism returns "'when' clause on line 4 duplicates 'when' clause on line 2 and is ignored"

#2

  it "does not allow calculation or method calls in a pattern" do
    -> {
      eval <<~RUBY
        case 0
        in 1 + 1
          true
        end
      RUBY
    }.should raise_error(SyntaxError, /unexpected|expected a delimiter after the predicates of a `when` clause/)
  end

Prism returns two errors:

  • "expected a delimiter after the patterns of an in clause"
  • "unexpected '+', ignoring it"

CRuby returns the following error message:

syntax error, unexpected '+', expecting `then' or ';' or '\n'
in 1 + 1
     ^

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