Fix "instance variable @options not initialized" warning in verbose mode #650
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 (
-w
or--verbose
or$VERBOSE = true
), when instantiating any renderer (subclass ofRedcarpet::Render::Base
) without parameters, warning is shown about@options
not initialized:(For example, it can be seen if running
RUBYOPT=-w rake test
)It's caused by accessing
@options
withrb_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_get
but 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
@options
in render objects: there are no reads of it and all options are passed to actual renderer in constructor only, overwriting@options
later is meaningless.Redcarpet::Markdown
object 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.