Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow functions named `fun'

  • Loading branch information...
commit 2aeda37a1eaa35aee65fb8fd2a3419f4e58338d9 1 parent 8f9e781
@quix authored
View
2  lib/pure/pure_private/extractor_parameters.rb
@@ -9,7 +9,7 @@ module ExtractorParameters
module_function
def extract(mod, method_name, file, line)
- if method_name == :fun
+ if method_name == :__fun
Hash.new
else
{
View
2  lib/pure/pure_private/extractor_ripper.rb
@@ -77,7 +77,7 @@ def process_fun(sexp)
)
if line
@defs[line] = {
- :name => :fun,
+ :name => :__fun,
:sexp => sexp[2],
}
true
View
2  lib/pure/pure_private/extractor_ruby_parser.rb
@@ -42,7 +42,7 @@ def process(sexp)
sexp[1][1] == nil and
sexp[1][2] == :fun
@defs[sexp[1].line] = {
- :name => :fun,
+ :name => :__fun,
:sexp => [sexp[2], sexp[3]],
}
sexp.clear
View
2  lib/pure/pure_private/singleton_features.rb
@@ -41,7 +41,7 @@ def fun(*args, &block)
fun_mod.module_eval {
define_method(node_sym, &block)
}
- spec = Extractor.extract(fun_mod, :fun, caller)
+ spec = Extractor.extract(fun_mod, :__fun, caller)
FunctionDatabase[fun_mod][node_sym] = spec.merge(
:name => node_sym,
:args => child_syms,
View
20 spec/fun_spec.rb
@@ -119,4 +119,24 @@ def height
end
end.compute(:f, 3).should == [:f]
end
+
+ it "should not preclude `def' definitions called `fun'" do
+ pure do
+ def amuse(fun)
+ fun*2
+ end
+
+ def fun(a, b)
+ a + b
+ end
+
+ def a
+ 3
+ end
+
+ def b
+ 5
+ end
+ end.compute(:amuse, 3).should == 16
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.