mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Add the loaded feature after no exception raised
Retrying after rescued `require` should try to load the same
library again.  [Bug #16607]
(cherry picked from commit 7d6903dc47)
			
			
This commit is contained in:
		
							parent
							
								
									7518b4e945
								
							
						
					
					
						commit
						c7e0ce6743
					
				
					 2 changed files with 8 additions and 2 deletions
				
			
		
							
								
								
									
										3
									
								
								load.c
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								load.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1007,7 +1007,6 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception)
 | 
			
		|||
		result = 0;
 | 
			
		||||
	    }
 | 
			
		||||
	    else if (!*ftptr) {
 | 
			
		||||
		rb_provide_feature(path);
 | 
			
		||||
		result = TAG_RETURN;
 | 
			
		||||
	    }
 | 
			
		||||
	    else {
 | 
			
		||||
| 
						 | 
				
			
			@ -1022,7 +1021,6 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception)
 | 
			
		|||
		    rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
 | 
			
		||||
		    break;
 | 
			
		||||
		}
 | 
			
		||||
                rb_provide_feature(path);
 | 
			
		||||
                result = TAG_RETURN;
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1056,6 +1054,7 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception)
 | 
			
		|||
        rb_exc_raise(ec->errinfo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (result == TAG_RETURN) rb_provide_feature(path);
 | 
			
		||||
    ec->errinfo = errinfo;
 | 
			
		||||
 | 
			
		||||
    RUBY_DTRACE_HOOK(REQUIRE_RETURN, RSTRING_PTR(fname));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -214,6 +214,13 @@ class TestRequire < Test::Unit::TestCase
 | 
			
		|||
    assert_syntax_error_backtrace {|req| require req}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_require_syntax_error_rescued
 | 
			
		||||
    assert_syntax_error_backtrace do |req|
 | 
			
		||||
      assert_raise_with_message(SyntaxError, /unexpected/) {require req}
 | 
			
		||||
      require req
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_load_syntax_error
 | 
			
		||||
    assert_syntax_error_backtrace {|req| load req}
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue