开发者

redundant nested repeat operator

Has anybody gotten this ruby warning before? "warning: redundant nes开发者_开发技巧ted repeat operator"

What does it mean?

I get it when I start Webrick

This is how my trace looks like:

c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/strexp.rb:4
1: warning: redundant nested repeat operator
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing
/route.rb:25: warning: redundant nested repeat operator
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/route.rb:46

I'm using Rails 3.0.5 and Ruby 1.9.2 p180


This happens when you have a regular expression with two repeat operators on a single atom. E.g.,

ruby-1.9.2-p180 :001 > re = /\w**/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80: 
    warning: redundant nested repeat operator: /\w**/
=> /\w**/ 

Given that the backtrace has what looks like routing libraries (I've not personally used the rack-mount gem), I'd guess one of your routes either has a redundant repeat operator in it, or is being reduced down to a regex which has one.


@michael's response got me to find the real problem:

If you have the following in your routes.rb,

match "/foo(/bar(/something)))" => "controller#action"

You get the warning mentioned above. It exists to warn you that /foo works, so does /foo/bar and so does /foo/bar/something

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜