From f8903e3a29ac0c44fb7417d8b8a1f4b62ef36743 Mon Sep 17 00:00:00 2001 From: Ilya Bylich Date: Fri, 3 Jan 2020 19:27:42 +0300 Subject: [PATCH] pop receiver when evaliing lvar as method call; dup argument ini putstring; call :to_s on a string in tostring --- executor.rb | 5 +++-- tags/language/alias_tags.txt | 3 --- tags/language/def_tags.txt | 1 - tags/language/encoding_tags.txt | 2 -- tags/language/hash_tags.txt | 1 - tags/language/predefined/data_tags.txt | 1 - tags/language/predefined/toplevel_binding_tags.txt | 1 - tags/language/regexp/encoding_tags.txt | 9 --------- tags/language/return_tags.txt | 13 ------------- tags/language/singleton_class_tags.txt | 1 - tags/language/string_tags.txt | 6 ------ 11 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 tags/language/encoding_tags.txt delete mode 100644 tags/language/predefined/toplevel_binding_tags.txt delete mode 100644 tags/language/regexp/encoding_tags.txt delete mode 100644 tags/language/string_tags.txt diff --git a/executor.rb b/executor.rb index 2925577..4153331 100644 --- a/executor.rb +++ b/executor.rb @@ -68,6 +68,7 @@ def execute_opt_send_without_block((options, _flag)) (local = vm.frame_stack.closest(&:eval?).locals.find_if_declared(name: mid)) # x = 1; eval("x") - x is a VCALL in eval, so maybe it's a local variable of the parent frame + _recv = pop result = local.value push(result) return @@ -515,7 +516,7 @@ def execute_newarray((size)) end def execute_putstring((string)) - push(string) + push(string.dup) end def execute_splatarray((_flag)) @@ -674,7 +675,7 @@ def execute_setn((n)) def execute_tostring(*) str = pop obj = pop - if str != obj.to_s + if str != obj.__send__(:to_s) # TODO: must be some raise here # if to_s failed to convert an object binding.irb diff --git a/tags/language/alias_tags.txt b/tags/language/alias_tags.txt index 56e0430..c8a9cc2 100644 --- a/tags/language/alias_tags.txt +++ b/tags/language/alias_tags.txt @@ -3,6 +3,3 @@ fails:The alias keyword operates on the class/module metaclass when used in inst fails:The alias keyword operates on the class/module metaclass when used in instance_exec fails:The alias keyword operates on methods defined via attr, attr_reader, and attr_accessor fails:The alias keyword is not allowed against Fixnum or String instances -fails:The alias keyword on top level defines the alias on Object -fails:The alias keyword can create a new global variable, synonym of the original -fails:The alias keyword can override an existing global variable and make them synonyms diff --git a/tags/language/def_tags.txt b/tags/language/def_tags.txt index 204b36b..1859952 100644 --- a/tags/language/def_tags.txt +++ b/tags/language/def_tags.txt @@ -4,7 +4,6 @@ fails:An instance method raises an error with too many arguments fails:An instance method definition with a splat requires the presence of any arguments that precede the * fails:An instance method with a default argument evaluates the default when required arguments precede it fails:An instance method with a default argument prefers to assign to a default argument before a splat argument -fails:A singleton method definition can be declared for a global variable fails:Redefining a singleton method does not inherit a previously set visibility fails:A nested method definition creates an instance method when evaluated in an instance method fails:A nested method definition creates a class method when evaluated in a class method diff --git a/tags/language/encoding_tags.txt b/tags/language/encoding_tags.txt deleted file mode 100644 index e0c8827..0000000 --- a/tags/language/encoding_tags.txt +++ /dev/null @@ -1,2 +0,0 @@ -fails:The __ENCODING__ pseudo-variable is the evaluated strings's one inside an eval -fails:The __ENCODING__ pseudo-variable is the encoding specified by a magic comment inside an eval diff --git a/tags/language/hash_tags.txt b/tags/language/hash_tags.txt index 03e5227..367b4a1 100644 --- a/tags/language/hash_tags.txt +++ b/tags/language/hash_tags.txt @@ -1,3 +1,2 @@ -fails:Hash literal freezes string keys on initialization fails:Hash literal raises a TypeError if any splatted elements keys are not symbols fails:Hash literal raises a TypeError if #to_hash does not return a Hash diff --git a/tags/language/predefined/data_tags.txt b/tags/language/predefined/data_tags.txt index f9e7ef8..4d238c7 100644 --- a/tags/language/predefined/data_tags.txt +++ b/tags/language/predefined/data_tags.txt @@ -1,2 +1 @@ -fails:The DATA constant does not exist when the main script contains no __END__ fails:The DATA constant is set even if there is no newline after __END__ diff --git a/tags/language/predefined/toplevel_binding_tags.txt b/tags/language/predefined/toplevel_binding_tags.txt deleted file mode 100644 index bd0606b..0000000 --- a/tags/language/predefined/toplevel_binding_tags.txt +++ /dev/null @@ -1 +0,0 @@ -fails:The TOPLEVEL_BINDING constant has no local variables in files required before the main script diff --git a/tags/language/regexp/encoding_tags.txt b/tags/language/regexp/encoding_tags.txt deleted file mode 100644 index fb3bd9f..0000000 --- a/tags/language/regexp/encoding_tags.txt +++ /dev/null @@ -1,9 +0,0 @@ -fails:Regexps with encoding modifiers supports /e (EUC encoding) -fails:Regexps with encoding modifiers supports /e (EUC encoding) with interpolation -fails:Regexps with encoding modifiers supports /e (EUC encoding) with interpolation /o -fails:Regexps with encoding modifiers supports /s (Windows_31J encoding) -fails:Regexps with encoding modifiers supports /s (Windows_31J encoding) with interpolation -fails:Regexps with encoding modifiers supports /s (Windows_31J encoding) with interpolation and /o -fails:Regexps with encoding modifiers supports /u (UTF8 encoding) -fails:Regexps with encoding modifiers supports /u (UTF8 encoding) with interpolation -fails:Regexps with encoding modifiers supports /u (UTF8 encoding) with interpolation and /o diff --git a/tags/language/return_tags.txt b/tags/language/return_tags.txt index a8016cc..f90d51a 100644 --- a/tags/language/return_tags.txt +++ b/tags/language/return_tags.txt @@ -3,17 +3,4 @@ fails:The return keyword within a block causes the method that lexically enclose fails:The return keyword within a block returns from the lexically enclosing method even in case of chained calls fails:The return keyword within a block returns from the lexically enclosing method even in case of chained calls(in yield) fails:The return keyword within a block causes the method to return even when the immediate parent has already returned -fails:The return keyword at top level stops file execution -fails:The return keyword at top level within if is allowed -fails:The return keyword at top level within while loop is allowed -fails:The return keyword at top level within a begin is allowed in begin block -fails:The return keyword at top level within a begin is allowed in ensure block -fails:The return keyword at top level within a begin is allowed in rescue block -fails:The return keyword at top level within a begin fires ensure block before returning -fails:The return keyword at top level within a begin fires ensure block before returning while loads file fails:The return keyword at top level within a begin swallows exception if returns in ensure block -fails:The return keyword at top level within a block is allowed -fails:The return keyword at top level within a class raises a SyntaxError -fails:The return keyword at top level file loading stops file loading and execution -fails:The return keyword at top level file requiring stops file loading and execution -fails:The return keyword at top level return with argument does not affect exit status diff --git a/tags/language/singleton_class_tags.txt b/tags/language/singleton_class_tags.txt index cbc7b96..c2bce5d 100644 --- a/tags/language/singleton_class_tags.txt +++ b/tags/language/singleton_class_tags.txt @@ -1,2 +1 @@ -fails:A singleton class has class String as the superclass of a String instance fails:A constant on a singleton class cannot be accessed via object::CONST diff --git a/tags/language/string_tags.txt b/tags/language/string_tags.txt deleted file mode 100644 index a0d5430..0000000 --- a/tags/language/string_tags.txt +++ /dev/null @@ -1,6 +0,0 @@ -fails:Ruby character strings taints the result of interpolation when an interpolated value is tainted -fails:Ruby character strings untrusts the result of interpolation when an interpolated value is untrusted -fails:Ruby character strings calls #to_s as a private method -fails:Ruby String interpolation creates a String having an Encoding compatible with all components -fails:Ruby String interpolation creates a String having the Encoding of the components when all are the same Encoding -fails:Ruby String interpolation raises an Encoding::CompatibilityError if the Encodings are not compatible