Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A strange problem: function returning nil instead returns random numbers #26

Open
realgenekim opened this issue May 18, 2019 · 4 comments
Assignees
Milestone

Comments

@realgenekim
Copy link

realgenekim commented May 18, 2019

Hi, @gnl — 

Keep up all the amazing work. Just ran into the strange problem... Here's a function without ghostwheel...

(defn should-return-nil
  [x]
  nil)
=> #'x.asin/should-return-nil
(should-return-nil "")
=> nil
(should-return-nil "")
=> nil

And here's the same function with ghostwheel — it returns seemingly random numbers. I'm wondering if I'm doing something wrong?

(>defn should-return-nil-gw
  [x] [string? => int?]
  nil)
=> [x.asin/should-return-nil-gw]

; this fails, as expected...
(should-return-nil-gw 12)
Syntax error (ExceptionInfo) compiling at (asin.clj:23:3).
Call to amazonreviews.asin/should-return-nil-gw did not conform to spec:
12 - failed: string? in: [0] at: [:args :x]

; this has surprising return value
(should-return-nil-gw "")
=> -6922
(should-return-nil-gw "")
=> 0
(should-return-nil-gw "")
=> -31855
  1. Shouldn't the return value fail the spec, as it is not nilable?
  2. Why is it returning seemingly random numbers?

Thank you!
Gene

@gnl
Copy link
Owner

gnl commented May 20, 2019

Hey @realgenekim – feature not a bug. :) see the 5th point here about spec-based stub generation:
https://github.com/gnl/ghostwheel#introduction

Admittedly, it's not as well documented as it should be and probably shouldn't be on by default – will take care of that for the next release.

@gnl gnl added this to the 0.3.10 milestone May 20, 2019
@gnl gnl self-assigned this May 20, 2019
@realgenekim
Copy link
Author

@gnl Thanks for the quick reply! (And sorry for my delayed response.)

When I read your explanation, I breathed a huge sigh of relief, because I thought I was doing something crazy-wrong. :)

Yes, this is a really neat feature! But I agree with you — perhaps this should be disabled by default, because of how jarring it is if you're not expecting it.

Thanks again!

@gnl
Copy link
Owner

gnl commented May 21, 2020

👋 Hi. I'm posting this same comment to all issue threads to just give a quick heads up that the project, despite rumours and some evidence to the contrary, is not dead. It was hibernating for a little while and now nearing the long-awaited next release, which will fix some long-standing issues (and introduce some breaking changes to the config).

I'll be reviewing all open issues and PRs over the next couple of weeks, so stay tuned and thanks for the patience.

See also this Slack thread

@gnl
Copy link
Owner

gnl commented Jul 20, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants