8000 * parse.y (parser_yylex): suppress an extra error message after · devrandom/ruby@b337740 · GitHub
[go: up one dir, main page]

Skip to content

Commit b337740

Browse files
committed
* parse.y (parser_yylex): suppress an extra error message after
numeric literal without digits. based on a patch from ujihisa . in [ruby-dev:39811]. [ruby-dev:39798] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent cf88448 commit b337740

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Mon Nov 30 11:00:12 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* parse.y (parser_yylex): suppress an extra error message after
4+
numeric literal without digits. based on a patch from ujihisa .
5+
in [ruby-dev:39811]. [ruby-dev:39798]
6+
17
Sun Nov 29 16:56:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
28

39
* vm_eval.c (check_funcall_failed): pass ID. [ruby-core:26934]

parse.y

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6902,6 +6902,7 @@ parser_yylex(struct parser_params *parser)
69026902
c = nextc();
69036903
}
69046904
if (c == '0') {
6905+
#define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
69056906
int start = toklen();
69066907
c = nextc();
69076908
if (c == 'x' || c == 'X') {
@@ -6922,7 +6923,7 @@ parser_yylex(struct parser_params *parser)
69226923
pushback(c);
69236924
tokfix();
69246925
if (toklen() == start) {
6925-
yyerror("numeric literal without digits");
6926+
no_digits();
69266927
}
69276928
else if (nondigit) goto trailing_uc;
69286929
set_yylval_literal(rb_cstr_to_inum(tok(), 16, FALSE));
@@ -6946,7 +6947,7 @@ parser_yylex(struct parser_params *parser)
69466947
pushback(c);
69476948
tokfix();
69486949
if (toklen() == start) {
6949-
yyerror("numeric literal without digits");
6950+
no_digits();
69506951
}
69516952
else if (nondigit) goto trailing_uc;
69526953
set_yylval_literal(rb_cstr_to_inum(tok(), 2, FALSE));
@@ -6970,7 +6971,7 @@ parser_yylex(struct parser_params *parser)
69706971
pushback(c);
69716972
tokfix();
69726973
if (toklen() == start) {
6973-
yyerror("numeric literal without digits");
6974+
no_digits();
69746975
}
69756976
else if (nondigit) goto trailing_uc;
69766977
set_yylval_literal(rb_cstr_to_inum(tok(), 10, FALSE));
@@ -6984,7 +6985,7 @@ parser_yylex(struct parser_params *parser)
69846985
/* prefixed octal */
69856986
c = nextc();
69866987
if (c == -1 || c == '_' || !ISDIGIT(c)) {
6987-
yyerror("numeric literal without digits");
6988+
no_digits();
69886989
}
69896990
}
69906991
if (c >= '0' && c <= '7') {

test/ruby/test_literal.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ def test_integer
211211
}
212212
}
213213
}
214+
bug2407 = '[ruby-dev:39798]'
215+
head.each {|h|
216+
if /^0/ =~ h
217+
begin
218+
eval("#{h}_")
219+
rescue SyntaxError => e
220+
assert_match(/numeric literal without digits\Z/, e.message, bug2407)
221+
end
222+
end
223+
}
214224
end
215225

216226
def test_float

0 commit comments

Comments
 (0)
0