Last active
January 11, 2023 01:56
-
-
Save igaiga/885cfd55d6766798735cedfb8e1ca185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "typeprof" | |
target_code = <<~STR | |
result = [] | |
a = [1,2,3].each do |x| | |
result << x * 2 | |
end | |
p a | |
p result | |
STR | |
# これだと動く | |
# rb_file = File.join(__dir__, "./tp_target.rb") | |
# rb_files = [rb_file] | |
rb_file = StringIO.new(target_code) | |
rb_files = [rb_file] | |
rbs_files = [] | |
output = StringIO.new("") | |
options = {} | |
options[:show_untyped] = true | |
options[:show_errors] = true | |
options[:show_indicator] = false | |
options[:show_typeprof_version] = false | |
config = TypeProf::ConfigData.new( | |
rb_files: rb_files, | |
rbs_files: rbs_files, | |
output: output, | |
options: options, | |
verbose: 0, | |
) | |
TypeProf.analyze(config) | |
p output = output.string | |
# lib/ruby/gems/3.2.0/gems/typeprof-0.21.3/lib/typeprof/analyzer.rb:1053:in `type_profile': undefined method `absolute_path' for #<StringIO:0x00000001076bfa50> (NoMethodError) | |
# | |
# @loaded_files[iseq.absolute_path] = true | |
# ^^^^^^^^^^^^^^ | |
# from lib/ruby/gems/3.2.0/gems/typeprof-0.21.3/lib/typeprof/config.rb:123:in `analyze' | |
# from tp0111.rb:32:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment