From 54716fe7ebbf20b5e91fdbe9b65e0bedb0c4836a Mon Sep 17 00:00:00 2001 From: ko1 Date: Fri, 23 Oct 2015 19:02:55 +0000 Subject: * ruby.c: introduce --enable-frozen-string-literal-debug option. If this option is enabled, the modify error will be: can't modify frozen String (RuntimeError) => can't modify frozen String, created at test.rb:3 (RuntimeError) * iseq.h: add compile option frozen_string_literal_debug. * compile.c: catch up this fix. * error.c (rb_error_frozen): ditto. * iseq.c (set_compile_option_from_hash): ditto. * test/ruby/test_rubyoptions.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 35f343a25c..0d5137bd1f 100644 --- a/ruby.c +++ b/ruby.c @@ -69,6 +69,7 @@ enum feature_flag_bits { feature_did_you_mean, feature_rubyopt, feature_frozen_string_literal, + feature_frozen_string_literal_debug, feature_flag_count }; @@ -126,6 +127,7 @@ cmdline_options_init(struct cmdline_options *opt) opt->features &= ~FEATURE_BIT(gems); #endif opt->features &= ~FEATURE_BIT(frozen_string_literal); + opt->features &= ~FEATURE_BIT(frozen_string_literal_debug); return opt; } @@ -739,6 +741,7 @@ enable_option(const char *str, int len, void *arg) SET_WHEN_ENABLE(did_you_mean); SET_WHEN_ENABLE(rubyopt); SET_WHEN_ENABLE(frozen_string_literal); + SET_WHEN_ENABLE(frozen_string_literal_debug); if (NAME_MATCH_P("all", str, len)) { *(unsigned int *)arg = ~0U; return; @@ -754,6 +757,7 @@ disable_option(const char *str, int len, void *arg) UNSET_WHEN_DISABLE(did_you_mean); UNSET_WHEN_DISABLE(rubyopt); UNSET_WHEN_DISABLE(frozen_string_literal); + UNSET_WHEN_DISABLE(frozen_string_literal_debug); if (NAME_MATCH_P("all", str, len)) { *(unsigned int *)arg = 0U; return; @@ -1474,6 +1478,11 @@ process_options(int argc, char **argv, struct cmdline_options *opt) rb_hash_aset(option, ID2SYM(rb_intern_const("frozen_string_literal")), Qtrue); rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option); } + if (opt->features & FEATURE_BIT(frozen_string_literal_debug)) { + VALUE option = rb_hash_new(); + rb_hash_aset(option, ID2SYM(rb_intern_const("frozen_string_literal_debug")), Qtrue); + rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option); + } #if UTF8_PATH opt->script_name = str_conv_enc(opt->script_name, rb_utf8_encoding(), lenc); opt->script = RSTRING_PTR(opt->script_name); -- cgit v1.2.3