rubinius/rubinius — Issue #1474: __LINE__ is incorrectly cached.
Author: ConradIrwin
Created: 2011-12-27 18:47:09+00:00
State: open

```ruby
eval("__LINE__", binding, "(test)", 2)
# => 2
eval("__LINE__", binding, "(test)", 3)
#=> 2
```

I had a look at fixing this by adding an `AST::Line` (like `AST::File`), but I'm not sure that would be fruitful because ruby_sourceline is used pervasively, and it was confusing to try and redefine that to be the "difference between the first line and the current line" while keeping track of the value for the first line just as we keep track of the current file in eval().

Another fix I tried was to try to avoid caching code that contains the string `__LINE__` in the `Compiler#compile_eval`, but that only paper's over the problem — the incorrect line number is still noticable in `caller()` etc.

This bug confuses the fixes to Issue #953.