1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

14 commits

Author SHA1 Message Date
Yusuke Endoh
e9a4cc02b4 [ruby/error_highlight] Add a test to check if it is robust against a spoofed filename
Previously, RubyVM::AST.of opened a wrong file if the iseq's file path is spoofed.

```
module Dummy
  binding.irb
end
```

```
$ ruby test.rb

From: test.rb @ line 2 :

    1: module Dummy
 => 2:   binding.irb
    3: end

irb(Dummy):001:0> foo
/home/mame/work/ruby/local/lib/ruby/3.1.0/error_highlight/base.rb:412:in `spot_colon2': undefined method `last_lineno' for nil:NilClass (NoMethodError)

      if nd_parent.last_lineno == @node.last_lineno
                  ^^^^^^^^^^^^
```

Found by @kateinoigakukun

This issue is already fixed in the interpreter side.
This change just adds a test for the case.

https://github.com/ruby/error_highlight/commit/f3626b9032
2022-01-04 23:18:37 +09:00
Christian Boos
11b1ebe606 [ruby/error_highlight] Fix the spurious TypeError.
When we have no backtrace locations, we can't have the highlight,
so just return the message.

https://github.com/ruby/error_highlight/commit/9f5c639494
2022-01-04 23:09:01 +09:00
Christian Boos
e22218b510 [ruby/error_highlight] Reproduce the error seen when calling .to_s in embedded Ruby
The test fails with the following error:

Error: test_simulate_funcallv_from_embedded_ruby(ErrorHighlightTest): TypeError: wrong argument type nil (expected method)

https://github.com/ruby/error_highlight/commit/52943c9cd2
2022-01-04 23:09:00 +09:00
Yusuke Endoh
4c32fcb84f [ruby/error_highlight] Make the formatter mechanism support Ractor
Now the formatter configuration is per Ractor. DefaultFormatter is used
if not set.

DefaultFormatter#message_for is now a class method to allow sub-Ractors
to call the method.

https://github.com/ruby/error_highlight/commit/9fbaa8ab7c
2021-10-27 11:29:20 +09:00
Yusuke Endoh
5e9598baea [ruby/error_highlight] Fixed the argument for DidYouMean.formatter=
Looks like this bug was hidden by did_you_mean's rescuing any
exceptions.

https://github.com/ruby/error_highlight/commit/7a8f0b4796
2021-08-20 16:27:07 +09:00
Masataka Pocke Kuwabara
242f024bcb [ruby/error_highlight] Keep it work if paren exists after receiver
https://github.com/ruby/error_highlight/commit/b79d679bbd
2021-07-31 22:15:16 +09:00
Hiroshi SHIBATA
a4df7cb338
Partly picking 25ef7dbeda (diff-1ce41a048bf2c08aa7bf25b741e9d3a4e08ea03f0d80bc6b8ee6d1c3c259704dR1022) 2021-07-29 16:26:15 +09:00
Nobuyoshi Nakada
29ed9d1aaa [ruby/error_highlight] Fix leaked tempfiles
https://github.com/ruby/error_highlight/commit/8b353a10a7
2021-07-16 15:25:13 +09:00
Yusuke Endoh
a5d6ea9266 [ruby/error_highlight] Set the binary mode for Tempfile creation in a test
https://github.com/ruby/error_highlight/commit/8273d3b6f2
2021-07-13 20:30:20 +09:00
Yusuke Endoh
5fd5d71a4b [ruby/error_highlight] Support a file that has no final newline
https://github.com/ruby/error_highlight/commit/9d671284cb
2021-07-13 16:54:17 +09:00
Yusuke Endoh
23c8bc367c [ruby/error_highlight] Support hard tabs
Now, the highlight line is created by replacing non-tab characters with
spaces, and keeping all hard tabs as-is. This means the highlight line
has the completely same indentation as the code snippet line.

Fixes 

https://github.com/ruby/error_highlight/commit/38f20fa542
2021-07-13 16:51:02 +09:00
Yusuke Endoh
84fea8ee39 [ruby/error_highlight] Update a test for multibyte characters
https://github.com/ruby/error_highlight/commit/2fc70d7f8e
2021-07-12 16:48:52 +09:00
Yusuke Endoh
f428ced69c [ruby/error_highlight] Experimentally support a custom formatter
https://github.com/ruby/error_highlight/commit/f40a1de20e
2021-06-30 12:49:18 +09:00
Yusuke Endoh
9438c99590 Rename error_squiggle to error_highlight 2021-06-29 23:45:49 +09:00
Renamed from test/error_squiggle/test_error_squiggle.rb (Browse further)