nex3/sass — Issue #201: image-url helper raises an exception when used inline
Author: awd-switzerland
Created: 2011-10-26 08:47:16+00:00
State: open

The following snipped in _some_partial.haml fails reproducably with sass 3.1.10, rails 3.1.1 and ruby 1.9.2p290:

%style(type="text/css")
:sass
#whatever
background-image: image-url('some/asset.png')

If you put the exact same piece of sass into an external sass file, no exception is raised.

The exception we get is:

NoMethodError
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]

Backtrace (up to the entry point from actionpack, we can provide the rest too if necessary):

sass-rails (3.1.4) lib/sass/rails/helpers.rb:40:in `resolver'
sass-rails (3.1.4) lib/sass/rails/helpers.rb:25:in `image_url'
sass (3.1.10) lib/sass/script/funcall.rb:88:in `_perform'
sass (3.1.10) lib/sass/script/node.rb:40:in `perform'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:214:in `visit_prop'
sass (3.1.10) lib/sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
sass (3.1.10) lib/sass/tree/visitors/base.rb:53:in `map'
sass (3.1.10) lib/sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:39:in `with_environment'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:26:in `visit_children'
sass (3.1.10) lib/sass/tree/visitors/base.rb:37:in `block in visit'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:234:in `visit_rule'
sass (3.1.10) lib/sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
sass (3.1.10) lib/sass/tree/visitors/base.rb:53:in `map'
sass (3.1.10) lib/sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:39:in `with_environment'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:26:in `visit_children'
sass (3.1.10) lib/sass/tree/visitors/base.rb:37:in `block in visit'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:47:in `visit_root'
sass (3.1.10) lib/sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/tree/visitors/perform.rb:7:in `visit'
sass (3.1.10) lib/sass/tree/root_node.rb:20:in `render'
sass (3.1.10) lib/sass/engine.rb:300:in `_render'
sass (3.1.10) lib/sass/engine.rb:248:in `block in render'
sass (3.1.10) lib/sass/util.rb:297:in `silence_sass_warnings'
sass (3.1.10) lib/sass/engine.rb:248:in `render'
haml (3.1.3) lib/haml/filters.rb:311:in `render'
haml (3.1.3) lib/haml/filters.rb:71:in `render_with_options'
haml (3.1.3) lib/haml/filters.rb:121:in `block in compile'
haml (3.1.3) lib/haml/filters.rb:99:in `instance_eval'
haml (3.1.3) lib/haml/filters.rb:99:in `compile'
haml (3.1.3) lib/haml/filters.rb:80:in `internal_compile'
haml (3.1.3) lib/haml/compiler.rb:210:in `compile_filter'
haml (3.1.3) lib/haml/compiler.rb:447:in `compile'
haml (3.1.3) lib/haml/compiler.rb:446:in `block (2 levels) in compile'
haml (3.1.3) lib/haml/compiler.rb:446:in `each'
haml (3.1.3) lib/haml/compiler.rb:446:in `block in compile'
haml (3.1.3) lib/haml/compiler.rb:170:in `compile_tag'
haml (3.1.3) lib/haml/compiler.rb:447:in `compile'
haml (3.1.3) lib/haml/compiler.rb:446:in `block (2 levels) in compile'
haml (3.1.3) lib/haml/compiler.rb:446:in `each'
haml (3.1.3) lib/haml/compiler.rb:446:in `block in compile'
haml (3.1.3) lib/haml/compiler.rb:48:in `compile_root'
haml (3.1.3) lib/haml/compiler.rb:447:in `compile'
haml (3.1.3) lib/haml/engine.rb:124:in `initialize'
haml (3.1.3) lib/haml/template/plugin.rb:34:in `new'
haml (3.1.3) lib/haml/template/plugin.rb:34:in `compile'
haml (3.1.3) lib/haml/template/plugin.rb:39:in `call'
actionpack (3.1.1) lib/action_view/template.rb:253:in `compile'

Thanks for having a look at it.