• KOBAYASHI Shuji's avatar
    Refine output of `mrb_print_error()` · 29ecc384
    KOBAYASHI Shuji authored
    The following improvements are made according to Ruby's behavior:
    
    - Match location number to index.
    - Remove duplicate most recent call output.
    - Fix that first call is not output when array (unpacked) backtrace.
    
    ### Example
    
      ```ruby
      def a; raise "error!" end
      def b; a end
      begin
        b
      rescue => e
        e.backtrace if ARGV[0] == "unpack"  # unpack backtrace
        raise e
      end
      ```
    
    #### Before this patch:
    
      ```
      $ bin/mruby example.rb unpack
      trace (most recent call last):
        [0] example.rb:2:in b
        [1] example.rb:1:in a
      example.rb:1: error! (RuntimeError)
      ```
    
    #### After this patch:
    
      ```
      $ bin/mruby example.rb unpack
      trace (most recent call last):
        [2] example.rb:4
        [1] example.rb:2:in b
      example.rb:1:in a: error! (RuntimeError)
      ```
    29ecc384
backtrace.c 5.95 KB