Bug #2407
closednumeric literal without digits
Description
=begin
以下のような実験をすると、0o_のパターンの時だけなぜか"numeric literal without digits"なる警告が出るようです。
zsh % ruby -e'0123456789'
-e:1: Invalid octal digit
0123456789
^
zsh %
zsh % ruby -e'0o123456789'
-e:1: Invalid octal digit
0o123456789
^
zsh %
zsh % ruby -e'0_123456789'
-e:1: Invalid octal digit
0_123456789
^
zsh %
zsh % ruby -e'0o_123456789'
-e:1: numeric literal without digits
0o_123456789
^
-e:1: syntax error, unexpected tIDENTIFIER, expecting $end
=end
Files
Updated by matz (Yukihiro Matsumoto) almost 16 years ago
=begin
まつもと ゆきひろです
In message "Re: [Bug #2407] numeric literal without digits"
on Fri, 27 Nov 2009 21:47:25 +0900, Shyouhei Urabe redmine@ruby-lang.org writes:
|以下のような実験をすると、0o_のパターンの時だけなぜか"numeric literal without digits"なる警告が出るようです。
0o_, 0x_ などprefixの直後に _ が来た場合には、このエラーを意
図的に出しています。_というのは数値表現の数字と数字の間に入る
もので、prefixと数字の間に入るものではない、と考えたからです。
「エラーメッセージがわかりにくい」とか「prefixと数値の間に _
が入って何が悪い」などのいう指摘は、今後考慮しないとは言いま
せんが、少なくとも現時点ではこれは仕様です。
=end
Updated by matz (Yukihiro Matsumoto) almost 16 years ago
=begin
まつもと ゆきひろです
In message "Re: [Bug #2407] numeric literal without digits"
on Fri, 27 Nov 2009 21:47:25 +0900, Shyouhei Urabe redmine@ruby-lang.org writes:
|以下のような実験をすると、0o_のパターンの時だけなぜか"numeric literal without digits"なる警告が出るようです。
0o_, 0x_ などprefixの直後に _ が来た場合には、このエラーを意
図的に出しています。_というのは数値表現の数字と数字の間に入る
もので、prefixと数字の間に入るものではない、と考えたからです。
「エラーメッセージがわかりにくい」とか「prefixと数値の間に _
が入って何が悪い」などのいう指摘は、今後考慮しないとは言いま
せんが、少なくとも現時点ではこれは仕様です。
=end
Updated by shyouhei (Shyouhei Urabe) almost 16 years ago
=begin
だとしても"unexpected tIDENTIFIER, expecting $end"ってのは変じゃないですか?
=end
Updated by ujihisa (Tatsuhiro Ujihisa) almost 16 years ago
- File dont_show_unexpected_tIDENTIFIER_error_in_numeric_literal_without_digits.patch dont_show_unexpected_tIDENTIFIER_error_in_numeric_literal_without_digits.patch added
=begin
0o_, 0x_ などprefixの直後に _ が来た場合には、このエラーを意
図的に出しています。_というのは数値表現の数字と数字の間に入る
もので、prefixと数字の間に入るものではない、と考えたからです。
だとしても"unexpected tIDENTIFIER, expecting $end"ってのは変じゃないですか?
というわけで、0o_, 0x_などの場合に"numeric literal without digits"だけ出力して
"unexpected tIDENTIFIER, expecting $end"は出力しないようにする小さなパッチを添付します。
0o, 0xだけでなく、ついでに0b, 0dの部分も対応しました。
make testに通ります。
BEFORE:
$ ruby192 -e '0x_'
-e:1: numeric literal without digits
-e:1: syntax error, unexpected tIDENTIFIER, expecting $end
AFTER:
$ ruby192 -e '0x_'
-e:1: numeric literal without digits
=end
Updated by nobu (Nobuyoshi Nakada) almost 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r25962.
Shyouhei, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end