Skip to content

Conversation

@sinsoku
Copy link
Contributor

@sinsoku sinsoku commented Sep 15, 2025

I encountered the following error:

/Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:10:in `block in typecheck_for_module': undefined method `args' for an instance of TypeProf::Core::Type::Singleton (NoMethodError)

            f_args.zip(ty.args) do |f_arg_node, a_arg_ty|
                         ^^^^^
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/graph/vertex.rb:11:in `each_key'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/graph/vertex.rb:11:in `each_type'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:5:in `typecheck_for_module'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:669:in `typecheck'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:483:in `block in typecheck'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:482:in `each'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:482:in `typecheck'

The args method is only defined on Type::Instance, so it adds a conditional expression to avoid the error.

I encountered the following error:

```
/Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:10:in `block in typecheck_for_module': undefined method `args' for an instance of TypeProf::Core::Type::Singleton (NoMethodError)

            f_args.zip(ty.args) do |f_arg_node, a_arg_ty|
                         ^^^^^
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/graph/vertex.rb:11:in `each_key'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/graph/vertex.rb:11:in `each_type'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:5:in `typecheck_for_module'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:669:in `typecheck'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:483:in `block in typecheck'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:482:in `each'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:482:in `typecheck'
```

The `args` method is only defined on `Type::Instance`, so it
adds a conditional expression to avoid the error.
@sinsoku sinsoku force-pushed the fix-NoMethodError-in-Singleton branch from 595059f to 76e5586 Compare October 12, 2025 04:54
@sinsoku
Copy link
Contributor Author

sinsoku commented Oct 12, 2025

I was able to create a scenario that reproduced the issue, so I force-pushed it.

I found this issue while analyzing files in Redmine v6.10.
The file is at https://github.com/redmine/redmine/blob/6.1.0/lib/redmine/syntax_highlighting.rb.

The steps to reproduce are as follows:

$ git clone --depth 1 --branch 6.1.0 https://github.com/redmine/redmine.git tmp/redmine
$ bin/typeprof tmp/redmine/lib/redmine/syntax_highlighting.rb
# TypeProf 0.30.1

[0/1] tmp/redmine/lib/redmine/syntax_highlighting.rb/Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:10:in 'block in TypeProf::Core::AST.typecheck_for_module': undefined method 'args' for an instance of TypeProf::Core::Type::Singleton (NoMethodError)

            f_args.zip(ty.args) do |f_arg_node, a_arg_ty|
                         ^^^^^
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/graph/vertex.rb:11:in 'Hash#each_key'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/graph/vertex.rb:11:in 'TypeProf::Core::BasicVertex#each_type'
        from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/ast/sig_type.rb:5:in 'TypeProf::Core::AST.typecheck_for_module'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant