mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Check syntax warnings in built-in scripts
This commit is contained in:
parent
0d16c36d0a
commit
0283b5ddb4
Notes:
git
2024-09-25 02:18:59 +00:00
@ -8,6 +8,22 @@ SUBLIBS = {}
|
||||
REQUIRED = {}
|
||||
BUILTIN_ATTRS = %w[leaf inline_block use_block]
|
||||
|
||||
module CompileWarning
|
||||
@@warnings = 0
|
||||
|
||||
def warn(message)
|
||||
@@warnings += 1
|
||||
super
|
||||
end
|
||||
|
||||
def self.reset
|
||||
w, @@warnings = @@warnings, 0
|
||||
w.nonzero?
|
||||
end
|
||||
end
|
||||
|
||||
Warning.extend CompileWarning
|
||||
|
||||
def string_literal(lit, str = [])
|
||||
while lit
|
||||
case lit.first
|
||||
@ -300,7 +316,15 @@ def mk_builtin_header file
|
||||
|
||||
# bs = { func_name => argc }
|
||||
code = File.read(file)
|
||||
collect_iseq RubyVM::InstructionSequence.compile(code).to_a
|
||||
begin
|
||||
verbose, $VERBOSE = $VERBOSE, true
|
||||
collect_iseq RubyVM::InstructionSequence.compile(code, base).to_a
|
||||
ensure
|
||||
$VERBOSE = verbose
|
||||
end
|
||||
if warnings = CompileWarning.reset
|
||||
raise "#{warnings} warnings in #{file}"
|
||||
end
|
||||
collect_builtin(base, Ripper.sexp(code), 'top', bs = {}, inlines = {})
|
||||
|
||||
StringIO.open do |f|
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user