Skip to content
This repository

Fix halt(invoke) breaks its argument #613

merged 1 commit into from about 1 year ago

2 participants

Naotoshi Seo Konstantin Haase
Naotoshi Seo

When I passed an rack array variable to halt like


the halt method breaks its argument, actually in invoke method.

def invoke
  res = catch(:halt) { yield }
  res = [res] if Fixnum === res or String === res
  if Array === res and Fixnum === res.first
  elsif res.respond_to? :each
    body res
  nil # avoid double setting the same response tuple twice

See there is res.shift and res.pop. It finally breaks my @@forbidden variable which is returned by catch(:halt) { yield }.
My question is "is this a desired behavior?" If not, let's fix it. This is a pull request to fix it.

Konstantin Haase rkh merged commit eed4f71 into from January 16, 2013
Konstantin Haase rkh closed this January 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jan 17, 2013
Naotoshi Seo dup 6cbff56
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 0 deletions. Show diff stats Hide diff stats

  1. 1  lib/sinatra/base.rb
1  lib/sinatra/base.rb
@@ -949,6 +949,7 @@ def invoke
949 949
       res = catch(:halt) { yield }
950 950
       res = [res] if Fixnum === res or String === res
951 951
       if Array === res and Fixnum === res.first
+        res = res.dup
952 953
953 954
954 955

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.