Skip to content

Incorrect line number reported in "already initialized constant" warining #1424

@VladRassokhin

Description

@VladRassokhin

Given ruby file

MY_CONST = __LINE__
p MY_CONST
MY_CONST = __LINE__
p MY_CONST
MY_CONST = __LINE__
p MY_CONST

When run in ruby-2.0 (MRI) output is:

1
1.rb:3: warning: already initialized constant MY_CONST
1.rb:1: warning: previous definition of MY_CONST was here
3
1.rb:5: warning: already initialized constant MY_CONST
1.rb:3: warning: previous definition of MY_CONST was here
5

With JRuby (1.7.10 and older) got:

1
1.rb:4 warning: already initialized constant MY_CONST
3
1.rb:6 warning: already initialized constant MY_CONST
5 

As you can see JRuby reports wrong line number in warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions