Skip to content

Comments

fix: Remove duplicate method definitions in QueryCursor#99

Merged
stackmystack merged 1 commit intoFaveod:masterfrom
yancya:fix/query-cursor-method-redefined-warnings
Feb 19, 2026
Merged

fix: Remove duplicate method definitions in QueryCursor#99
stackmystack merged 1 commit intoFaveod:masterfrom
yancya:fix/query-cursor-method-redefined-warnings

Conversation

@yancya
Copy link
Contributor

@yancya yancya commented Feb 11, 2026

Summary

  • init_query_cursor() in ext/tree_sitter/query_cursor.c had three methods defined twice, producing Ruby warnings on require 'tree_sitter':
    warning: method redefined; discarding old exec
    warning: method redefined; discarding old match_limit
    warning: method redefined; discarding old match_limit=
    
  • exec: rb_define_module_function internally defines both a singleton method and an instance method, then rb_define_method redefined the instance method → replaced with rb_define_singleton_method
  • match_limit / match_limit=: DECLARE_ACCESSOR macro and explicit rb_define_method calls both defined the same methods → removed the DECLARE_ACCESSOR call

Test plan

  • Added test/tree_sitter/query_cursor_test.rb that verifies no "method redefined" warnings are emitted when loading the extension
  • Test fails on master (warnings present), passes with fix (warnings gone)
  • bundle exec rake compile succeeds without errors

🤖 Generated with Claude Code

Copy link
Collaborator

@stackmystack stackmystack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission.
Another note on the commit message: too verbose, please remove all of the body, it's a useless read, the patch is small enough.

I can merge once patched.

…warnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yancya yancya force-pushed the fix/query-cursor-method-redefined-warnings branch from c7120eb to 85837e9 Compare February 12, 2026 19:03
@yancya
Copy link
Contributor Author

yancya commented Feb 12, 2026

Thanks for the review, @stackmystack!

I've addressed all the feedback:

  1. Commit message: Removed the verbose body, keeping only the title.
  2. Regex in test: Changed to /redefined/ as suggested.
  3. DECLARE_ACCESSOR: Restored the macro and removed the explicit rb_define_method calls for match_limit/match_limit= instead.
  4. Rubocop: Fixed style offenses in the test file (single quotes, %i[], &:read, argument alignment).

@yancya
Copy link
Contributor Author

yancya commented Feb 16, 2026

If you merge #100 first and rebase this PR, all CI tests should pass.

@stackmystack
Copy link
Collaborator

Thanks!

@stackmystack stackmystack merged commit 2cc3388 into Faveod:master Feb 19, 2026
36 of 37 checks passed
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.

2 participants