Project

General

Profile

Actions

Bug #20731

closed

warning: mismatched indentations at 'when' appears with prism enabled ruby

Added by yahonda (Yasuo Honda) 2 months ago. Updated 2 months ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-09-12T20:03:28Z master 0fc8422a05) +PRISM [x86_64-linux]
[ruby-core:119152]

Description

Steps to reproduce

  1. Create a case_sample.rb file
foo = :bar
case foo
  when :bar
    p 'foo is :bar'
  when :baz
    # do something
  else
    # do something
end
  1. Run this file against the latest Ruby 3.4.0dev with -w option to show warnings
$ ruby -w case_sample.rb

Expected behavior

It should show "foo is :bar" without any warnings as it runs against Ruby 3.3.5 or Ruby 3.4.0dev before prism is used by default

$ ruby -w case_sample.rb
"foo is :bar"
$ ruby -v
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]
$
$ ruby -w case_sample.rb
"foo is :bar"
$ ruby -v
ruby 3.4.0dev (2024-09-12T17:04:10Z master f2919bd11c) [x86_64-linux]
$

Actual behavior

It raises warning: mismatched indentations at 'when' with 'case' warnings as follows.

$ ruby -w case_sample.rb
case_sample.rb:3: warning: mismatched indentations at 'when' with 'case' at 2
case_sample.rb:5: warning: mismatched indentations at 'when' with 'case' at 2
"foo is :bar"
$ ruby -v
ruby 3.4.0dev (2024-09-12T20:03:28Z master 0fc8422a05) +PRISM [x86_64-linux]
$

Background

This repro is based on the tzinfo code below.

https://github.com/tzinfo/tzinfo/blob/d5893c99bbcd842af86023f02a84fac1659b3031/lib/tzinfo/timestamp.rb#L115-L127
https://github.com/tzinfo/tzinfo/blob/d5893c99bbcd842af86023f02a84fac1659b3031/lib/tzinfo/timestamp.rb#L147-L154

Actions

Also available in: Atom PDF

Like0
Like0Like1Like0Like0Like0Like0