Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync to latest prism #9802

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/prism/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@ def dump_options(options)
template << "C"
values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)

template << "C"
values << (options.fetch(:verbose, true) ? 0 : 1)

template << "C"
values << { nil => 0, "3.3.0" => 1, "latest" => 0 }.fetch(options[:version])

Expand Down
2 changes: 1 addition & 1 deletion lib/prism/prism.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = "prism"
spec.version = "0.19.0"
spec.version = "0.20.0"
spec.authors = ["Shopify"]
spec.email = ["ruby@shopify.com"]

Expand Down
6 changes: 0 additions & 6 deletions prism/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ID rb_option_id_filepath;
ID rb_option_id_encoding;
ID rb_option_id_line;
ID rb_option_id_frozen_string_literal;
ID rb_option_id_verbose;
ID rb_option_id_version;
ID rb_option_id_scopes;

Expand Down Expand Up @@ -130,8 +129,6 @@ build_options_i(VALUE key, VALUE value, VALUE argument) {
if (!NIL_P(value)) pm_options_line_set(options, NUM2INT(value));
} else if (key_id == rb_option_id_frozen_string_literal) {
if (!NIL_P(value)) pm_options_frozen_string_literal_set(options, value == Qtrue);
} else if (key_id == rb_option_id_verbose) {
pm_options_suppress_warnings_set(options, value != Qtrue);
} else if (key_id == rb_option_id_version) {
if (!NIL_P(value)) {
const char *version = check_string(value);
Expand Down Expand Up @@ -667,8 +664,6 @@ parse_input(pm_string_t *input, const pm_options_t *options) {
* integer or nil. Note that this is 1-indexed.
* * `frozen_string_literal` - whether or not the frozen string literal pragma
* has been set. This should be a boolean or nil.
* * `verbose` - the current level of verbosity. This controls whether or not
* the parser emits warnings. This should be a boolean or nil.
* * `version` - the version of prism that should be used to parse Ruby code. By
* default prism assumes you want to parse with the latest vesion of
* prism (which you can trigger with `nil` or `"latest"`). If you want to
Expand Down Expand Up @@ -1079,7 +1074,6 @@ Init_prism(void) {
rb_option_id_encoding = rb_intern_const("encoding");
rb_option_id_line = rb_intern_const("line");
rb_option_id_frozen_string_literal = rb_intern_const("frozen_string_literal");
rb_option_id_verbose = rb_intern_const("verbose");
rb_option_id_version = rb_intern_const("version");
rb_option_id_scopes = rb_intern_const("scopes");

Expand Down
2 changes: 1 addition & 1 deletion prism/extension.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PRISM_EXT_NODE_H
#define PRISM_EXT_NODE_H

#define EXPECTED_PRISM_VERSION "0.19.0"
#define EXPECTED_PRISM_VERSION "0.20.0"

#include <ruby.h>
#include <ruby/encoding.h>
Expand Down
9 changes: 0 additions & 9 deletions prism/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_l
options->frozen_string_literal = frozen_string_literal;
}

/**
* Set the suppress warnings option on the given options struct.
*/
PRISM_EXPORTED_FUNCTION void
pm_options_suppress_warnings_set(pm_options_t *options, bool suppress_warnings) {
options->suppress_warnings = suppress_warnings;
}

/**
* Set the version option on the given options struct by parsing the given
* string. If the string contains an invalid option, this returns false.
Expand Down Expand Up @@ -189,7 +181,6 @@ pm_options_read(pm_options_t *options, const char *data) {
}

options->frozen_string_literal = *data++;
options->suppress_warnings = *data++;
options->version = (pm_options_version_t) *data++;

uint32_t scopes_count = pm_options_read_u32(data);
Expand Down
15 changes: 0 additions & 15 deletions prism/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ typedef struct {

/** Whether or not the frozen string literal option has been set. */
bool frozen_string_literal;

/**
* Whether or not we should suppress warnings. This is purposefully negated
* so that the default is to not suppress warnings, which allows us to still
* create an options struct with zeroed memory.
*/
bool suppress_warnings;
} pm_options_t;

/**
Expand Down Expand Up @@ -119,14 +112,6 @@ PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, cons
*/
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal);

/**
* Set the suppress warnings option on the given options struct.
*
* @param options The options struct to set the suppress warnings value on.
* @param suppress_warnings The suppress warnings value to set.
*/
PRISM_EXPORTED_FUNCTION void pm_options_suppress_warnings_set(pm_options_t *options, bool suppress_warnings);

/**
* Set the version option on the given options struct by parsing the given
* string. If the string contains an invalid option, this returns false.
Expand Down
7 changes: 0 additions & 7 deletions prism/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,6 @@ struct pm_parser {
* a true value.
*/
bool frozen_string_literal;

/**
* Whether or not we should emit warnings. This will be set to false if the
* consumer of the library specified it, usually because they are parsing
* when $VERBOSE is nil.
*/
bool suppress_warnings;
};

#endif
12 changes: 2 additions & 10 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,7 @@ pm_parser_err_token(pm_parser_t *parser, const pm_token_t *token, pm_diagnostic_
*/
static inline void
pm_parser_warn(pm_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id) {
if (!parser->suppress_warnings) {
pm_diagnostic_list_append(&parser->warning_list, start, end, diag_id);
}
pm_diagnostic_list_append(&parser->warning_list, start, end, diag_id);
}

/**
Expand Down Expand Up @@ -17767,8 +17765,7 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
.in_keyword_arg = false,
.current_param_name = 0,
.semantic_token_seen = false,
.frozen_string_literal = false,
.suppress_warnings = false
.frozen_string_literal = false
};

// Initialize the constant pool. We're going to completely guess as to the
Expand Down Expand Up @@ -17814,11 +17811,6 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
parser->frozen_string_literal = true;
}

// suppress_warnings option
if (options->suppress_warnings) {
parser->suppress_warnings = true;
}

// version option
parser->version = options->version;

Expand Down
2 changes: 1 addition & 1 deletion prism/templates/lib/prism/serialize.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Prism

# The minor version of prism that we are expecting to find in the serialized
# strings.
MINOR_VERSION = 19
MINOR_VERSION = 20

# The patch version of prism that we are expecting to find in the serialized
# strings.
Expand Down
4 changes: 2 additions & 2 deletions prism/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* The minor version of the Prism library as an int.
*/
#define PRISM_VERSION_MINOR 19
#define PRISM_VERSION_MINOR 20

/**
* The patch version of the Prism library as an int.
Expand All @@ -24,6 +24,6 @@
/**
* The version of the Prism library as a constant string.
*/
#define PRISM_VERSION "0.19.0"
#define PRISM_VERSION "0.20.0"

#endif