Closed hachi8833 closed 6 years ago
I think this is because the parser has trouble parsing range type correctly (I guess it's related to the float parsing), and those #to_*
should be fine.
Can you not using range for now until I fix this?
Update: This is method parsing's issue, has nothing to do with float parsing
@hachi8833 Should be fixed at #533, can you check if the test cases are right and sufficient?
LGTM. Just adding some tests for the case:
{`
def foo(k)
b = "4".to_i
(1..k).each do |x|
b += x
end
b
end
foo(2)
`, 7},
{`
def foo(k)
b = "4".to_i
(k..10).each do |x|
b += x
end
b
end
foo(2)
`, 58},
{`
def four
4
end
def foo(k)
b = four
(1..k).each do |x|
b += x
end
b
end
foo(2)
`, 7},
{`
def four
4
end
def foo(k)
b = four
(k..10).each do |x|
b += x
end
b
end
foo(2)
`, 58},
The following causes invalid ArgumentError:
Same errors are occured if you change
"4".to_f
to"4".to_d
or"4".to_i
.But it is strange that the following works:
b = "4".to_f
"4".to_f
to4
Assumption
The following condition might be relevant:
String#to_*
#each
like:(k..10).each
causes the error(10..k).each
causes the errorputs (k..10)
orputs (10..k)
do not cause the error