diff --git a/lib/gir_ffi/builder/module.rb b/lib/gir_ffi/builder/module.rb
index <HASH>..<HASH> 100644
--- a/lib/gir_ffi/builder/module.rb
+++ b/lib/gir_ffi/builder/module.rb
@@ -100,12 +100,8 @@ module GirFFI
 
     def function_introspection_data function
       info = gir.find_by_name @namespace, function.to_s
-
-      if info.info_type == :function
-        info
-      else
-        nil
-      end
+      return nil if info.nil?
+      info.info_type == :function ? info : nil
     end
 
     def function_definition info, libmodule
diff --git a/test/generated_regress_test.rb b/test/generated_regress_test.rb
index <HASH>..<HASH> 100644
--- a/test/generated_regress_test.rb
+++ b/test/generated_regress_test.rb
@@ -984,6 +984,13 @@ class GeneratedRegressTest < MiniTest::Spec
       assert_equal 3423, result.get_int
     end
 
+    it "raises an appropriate NoMethodError when a function is not found" do
+      begin
+        Regress.this_method_does_not_exist
+      rescue => e
+        assert_equal "undefined method `this_method_does_not_exist' for Regress:Module", e.message
+      end
+    end
   end
 
 end
Make appropriate exception be thrown for missing module methods.