[ruby-core:95977] [Ruby master Feature#16377] Regexp literals should be frozen
| Newsgroups | gmane.comp.lang.ruby.core |
|---|---|
| Message-ID | <redmine.issue-16377.20191127114300.ac4db185a215dd9d@ruby-lang.org> |
Issue #16377 has been reported by byroot (Jean Boussier). ---------------------------------------- Feature #16377: Regexp literals should be frozen https://bugs.ruby-lang.org/issues/16377 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- The following script: ```ruby def mutate re = /foo/ state = re.instance_variable_get(:@state) re.instance_variable_set(:@state, state.to_i + 1) state end 3.times do p mutate end ``` Output this: ``` nil 1 2 ``` IMHO, you shouldn't be able to mutate an unduplicated literal. GitHub pull request: https://github.com/ruby/ruby/pull/2705 -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>