Skip to content

Instantly share code, notes, and snippets.

@tompng
Created January 29, 2025 09:27
Show Gist options
  • Save tompng/ec2751f230b8d427ccb210ca6bd7cde0 to your computer and use it in GitHub Desktop.
Save tompng/ec2751f230b8d427ccb210ca6bd7cde0 to your computer and use it in GitHub Desktop.
all_tokens = %w[
x
y
false
if
rescue
begin
end
=
def
=>
*
for
in
,
(
)
]
loop {
code = 7.times.map { all_tokens.sample }.join(' ')
next unless Prism.parse_success?(code) && Ripper.sexp(code)
$><<'|'# if rand < 0.001
$VERBOSE=nil
def x; $a<<:x; end; def y; $a<<:y; end
$a=[];$a<<begin;RubyVM::InstructionSequence.compile_parsey(code).eval; rescue;:err;end;
parsey=$a
def x; $a<<:x; end; def y; $a<<:y; end
$a=[];$a<<begin;RubyVM::InstructionSequence.compile_prism(code).eval; rescue;:err;end;
prism=$a
p code if parsey!=prism && !(parsey+prism).include?(:syntax)
}
___END__
# found differences
7
y = x rescue x in *
8
def false = y rescue y in x
x = begin end rescue x in false
9
x = x rescue x = x => *
x = y rescue false in * , y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment