Fix "instance variable @options not initialized" warning in verbose mode#650
Merged
robin850 merged 1 commit intovmg:masterfrom Mar 25, 2018
Merged
Conversation
238fa7d to
6b86656
Compare
Collaborator
|
Thank you very much @kolen ! :-) |
This was referenced Mar 11, 2021
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running in verbose mode (
-wor--verboseor$VERBOSE = true), when instantiating any renderer (subclass ofRedcarpet::Render::Base) without parameters, warning is shown about@optionsnot initialized:(For example, it can be seen if running
RUBYOPT=-w rake test)It's caused by accessing
@optionswithrb_iv_get:redcarpet/ext/redcarpet/rc_render.c
Lines 414 to 415 in 1c71f5e
Replaced it with
rb_attr_get, according to source, it's the same asrb_ivar_getbut without warnings and without conversion of undef to nil, not sure if it's the right method by design (seems that it is).Also not sure what is purpose for
@optionsin render objects: there are no reads of it and all options are passed to actual renderer in constructor only, overwriting@optionslater is meaningless.Redcarpet::Markdownobject adds its options to it when initialized but I can't figure out where these options are used (and these options are not for renderer but for "extensions"). Update: it's feature #560 and intended for custom renderers to be able to access "extension options" and not only renderer options passed in constructor.I can try to detect warnings in tests, but I'm not sure if it's right idea (it can only be done in quirky ways such as capturing stderr), so not changed tests for now.