Project

General

Profile

Actions

Bug #2407

closed

numeric literal without digits

Bug #2407: numeric literal without digits

Added by shyouhei (Shyouhei Urabe) almost 16 years ago. Updated over 14 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-11-24 trunk 25898) [x86_64-linux]
Backport:
[ruby-dev:39798]

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 Actions #1

=begin
まつもと ゆきひろです

In message "Re: [Bug #2407] numeric literal without digits"
on Fri, 27 Nov 2009 21:47:25 +0900, Shyouhei Urabe writes:

|以下のような実験をすると、0o_のパターンの時だけなぜか"numeric literal without digits"なる警告が出るようです。

0o_, 0x_ などprefixの直後に _ が来た場合には、このエラーを意
図的に出しています。_というのは数値表現の数字と数字の間に入る
もので、prefixと数字の間に入るものではない、と考えたからです。
「エラーメッセージがわかりにくい」とか「prefixと数値の間に _
が入って何が悪い」などのいう指摘は、今後考慮しないとは言いま
せんが、少なくとも現時点ではこれは仕様です。
=end

Updated by matz (Yukihiro Matsumoto) almost 16 years ago Actions #2

=begin
まつもと ゆきひろです

In message "Re: [Bug #2407] numeric literal without digits"
on Fri, 27 Nov 2009 21:47:25 +0900, Shyouhei Urabe writes:

|以下のような実験をすると、0o_のパターンの時だけなぜか"numeric literal without digits"なる警告が出るようです。

0o_, 0x_ などprefixの直後に _ が来た場合には、このエラーを意
図的に出しています。_というのは数値表現の数字と数字の間に入る
もので、prefixと数字の間に入るものではない、と考えたからです。
「エラーメッセージがわかりにくい」とか「prefixと数値の間に _
が入って何が悪い」などのいう指摘は、今後考慮しないとは言いま
せんが、少なくとも現時点ではこれは仕様です。

=end

Updated by shyouhei (Shyouhei Urabe) almost 16 years ago Actions #3

=begin
だとしても"unexpected tIDENTIFIER, expecting $end"ってのは変じゃないですか?
=end

Updated by ujihisa (Tatsuhiro Ujihisa) almost 16 years ago Actions #4

=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 Actions #5

  • 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

Actions

Also available in: PDF Atom