From 3f37e5bf43d4552f7249b965cbd330262034d2a5 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Mon, 9 Nov 2020 03:36:33 +0000 Subject: [PATCH] Fix to emit heredoc reminders on rescue postcontrol [Fix #195] --- lib/unparser/generation.rb | 4 +++- lib/unparser/writer/rescue.rb | 4 ++++ test/corpus/literal/dstr.rb | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/unparser/generation.rb b/lib/unparser/generation.rb index 099d8543..e553c58d 100644 --- a/lib/unparser/generation.rb +++ b/lib/unparser/generation.rb @@ -204,7 +204,9 @@ def emit_body_ensure_rescue(node) end def emit_rescue_postcontrol(node) - writer_with(Writer::Rescue, node).emit_postcontrol + writer = writer_with(Writer::Rescue, node) + writer.emit_postcontrol + writer.emit_heredoc_reminders end def emit_rescue_regular(node) diff --git a/lib/unparser/writer/rescue.rb b/lib/unparser/writer/rescue.rb index b2075cd2..889ec974 100644 --- a/lib/unparser/writer/rescue.rb +++ b/lib/unparser/writer/rescue.rb @@ -20,6 +20,10 @@ def emit_regular end end + def emit_heredoc_reminders + emitter(body).emit_heredoc_reminders + end + def emit_postcontrol visit(body) writer_with(Resbody, rescue_body).emit_postcontrol diff --git a/test/corpus/literal/dstr.rb b/test/corpus/literal/dstr.rb index 7dfa5762..2c1ed53c 100644 --- a/test/corpus/literal/dstr.rb +++ b/test/corpus/literal/dstr.rb @@ -17,6 +17,10 @@ #{} #{} HEREDOC +<<-HEREDOC rescue nil +#{} +a +HEREDOC "a#$1" "a#$a" "a#@a"