Project

General

Profile

Actions

Bug #10483

closed

Latest Ruby 2.1.4 update introduced backwards incompatible change related to boolean evaluation

Bug #10483: Latest Ruby 2.1.4 update introduced backwards incompatible change related to boolean evaluation

Added by jseeley (Joe Seeley) almost 11 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-darwin13.0]
[ruby-core:66120]

Description

The following, albeit ugly line of code (I didn't write it), worked in Ruby 2.1.1, but fails to evaluate in Ruby 2.1.4

= f.inputs (((q.pick == 'none' || (q.pick == 'one' && q.display_type != "default")) && q.display_type != 'label' ) ? nil : q_text(q, render_context)),:id => rg ? "q_#{q.id}_#{rg}" : "q_#{q.id}",'data-id' => q.id,  :class => "q_#{renderer} #{css_class} #{state_prefix_class}" do

This exists within a haml template and the piece that appears to be causing the problem is this section here.

(((q.pick == 'none' || (q.pick == 'one' && q.display_type != "default")) && q.display_type != 'label' )

When this is changed to span lines with some variable assignment, but no other changes it works correctly.

- qid = rg ? "q_#{q.id}_#{rg}" : "q_#{q.id}"
- q_render_context = (((q.pick == 'none' || (q.pick == 'one' && q.display_type != "default")) && q.display_type != 'label' ) ? nil : q_text(q, render_context))
= f.inputs q_render_context, :id => qid,'data-id' => q.id,  :class => "q_#{renderer} #{css_class} #{state_prefix_class}" do

This original version produces the following error output.

/Users/jseeley/code/eiacuc/app/views/partials/_question.html.haml:15: syntax error, unexpected keyword_do, expecting keyword_end     
/Users/jseeley/code/eiacuc/app/views/partials/_question.html.haml:53: syntax error, unexpected keyword_ensure, expecting end-of-input

The error was produced on haml v4.0.5 with Ruby 2.1.4; the error does not occur on haml v4.0.5 and Ruby 2.1.1 or prior.

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago Actions #1 [ruby-core:66124]

Joe Seeley wrote:

= f.inputs (((q.pick == 'none' || (q.pick == 'one' && q.display_type != "default")) && q.display_type != 'label' ) ? nil : q_text(q, render_context)),:id => rg ? "q_#{q.id}_#{rg}" : "q_#{q.id}",'data-id' => q.id,  :class => "q_#{renderer} #{css_class} #{state_prefix_class}" do

Where is the end?

The error was produced on haml v4.0.5 with Ruby 2.1.4; the error does not occur on haml v4.0.5 and Ruby 2.1.1 or prior.

Could you show the failed code if haml can emit the ruby code instead of evaluation?

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago Actions #2 [ruby-core:66296]

  • Status changed from Open to Feedback
  • Priority changed from Normal to 3

Updated by felixbuenemann (Felix Bünemann) almost 11 years ago Actions #3 [ruby-core:66593]

Nobuyoshi Nakada wrote:

Joe Seeley wrote:

= f.inputs (((q.pick == 'none' || (q.pick == 'one' && q.display_type != "default")) && q.display_type != 'label' ) ? nil : q_text(q, render_context)),:id => rg ? "q_#{q.id}_#{rg}" : "q_#{q.id}",'data-id' => q.id,  :class => "q_#{renderer} #{css_class} #{state_prefix_class}" do

Where is the end?

HAML automatically inserts end based on indentation.

Updated by naruse (Yui NARUSE) almost 8 years ago Actions #4

  • Target version deleted (2.2.0)

Updated by jeremyevans0 (Jeremy Evans) over 6 years ago Actions #5

  • Status changed from Feedback to Closed
Actions

Also available in: PDF Atom