Skip to content

Commit

Permalink
[ruby/prism] Remove warnings check from parse_success? method
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Dec 7, 2023
1 parent 8e86a43 commit 10bc0bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/prism.rb
Expand Up @@ -68,15 +68,15 @@ def self.load(source, serialized)
# :call-seq:
# Prism::parse_failure?(source, **options) -> bool
#
# Returns true if the source is invalid Ruby code.
# Returns true if the source parses with errors.
def self.parse_failure?(source, **options)
!parse_success?(source, **options)
end

# :call-seq:
# Prism::parse_file_failure?(filepath, **options) -> bool
#
# Returns true if the file at filepath is invalid Ruby code.
# Returns true if the file at filepath parses with errors.
def self.parse_file_failure?(filepath, **options)
!parse_file_success?(filepath, **options)
end
Expand Down
13 changes: 6 additions & 7 deletions prism/extension.c
Expand Up @@ -799,8 +799,7 @@ parse_lex_file(int argc, VALUE *argv, VALUE self) {
}

/**
* Parse the given input and return true if it parses without errors or
* warnings.
* Parse the given input and return true if it parses without errors.
*/
static VALUE
parse_input_success_p(pm_string_t *input, const pm_options_t *options) {
Expand All @@ -810,7 +809,7 @@ parse_input_success_p(pm_string_t *input, const pm_options_t *options) {
pm_node_t *node = pm_parse(&parser);
pm_node_destroy(&parser, node);

VALUE result = parser.error_list.size == 0 && parser.warning_list.size == 0 ? Qtrue : Qfalse;
VALUE result = parser.error_list.size == 0 ? Qtrue : Qfalse;
pm_parser_free(&parser);

return result;
Expand All @@ -820,8 +819,8 @@ parse_input_success_p(pm_string_t *input, const pm_options_t *options) {
* call-seq:
* Prism::parse_success?(source, **options) -> Array
*
* Parse the given string and return true if it parses without errors or
* warnings. For supported options, see Prism::parse.
* Parse the given string and return true if it parses without errors. For
* supported options, see Prism::parse.
*/
static VALUE
parse_success_p(int argc, VALUE *argv, VALUE self) {
Expand All @@ -840,8 +839,8 @@ parse_success_p(int argc, VALUE *argv, VALUE self) {
* call-seq:
* Prism::parse_file_success?(filepath, **options) -> Array
*
* Parse the given file and return true if it parses without errors or warnings.
* For supported options, see Prism::parse.
* Parse the given file and return true if it parses without errors. For
* supported options, see Prism::parse.
*/
static VALUE
parse_file_success_p(int argc, VALUE *argv, VALUE self) {
Expand Down
3 changes: 0 additions & 3 deletions test/prism/ruby_api_test.rb
Expand Up @@ -23,9 +23,6 @@ def test_ruby_api
def test_parse_success?
assert Prism.parse_success?("1")
refute Prism.parse_success?("<>")

assert Prism.parse_success?("m //", verbose: false)
refute Prism.parse_success?("m //", verbose: true)
end

def test_parse_file_success?
Expand Down

0 comments on commit 10bc0bd

Please sign in to comment.