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

save-identikon violates its own contract #23

Closed
greghendershott opened this issue May 25, 2019 · 4 comments · Fixed by #24
Closed

save-identikon violates its own contract #23

greghendershott opened this issue May 25, 2019 · 4 comments · Fixed by #24

Comments

@greghendershott
Copy link
Contributor

#lang racket/base
(require identikon)
(save-identikon "fourty-two"
                'png
                (identikon 1 1 "42"))

causes:

; save-identikon: broke its own contract
;   promised: boolean?
;   produced: #<void>
;   in: the range of
;       (->*
;        (string? (or/c symbol? string?) image?)
;        (#:quality number?)
;        boolean?)
;   contract from: <pkgs>/identikon/main.rkt
;   blaming: <pkgs>/identikon/main.rkt
;    (assuming the contract is correct)
;   at: <pkgs>/identikon/main.rkt:23.24

From what I can tell from a quick look at the source, this is because save-identikon calls functions that return void. Or, it raises an error.

  1. One fix would be to have save-identikon return #t.
  2. Another fix would be to change the contract (in main.rkt and the Scrbibble doc) to say it returns void?.

I think 2 better and almost went ahead and submitted a PR with that. But thought I should ask first.

@DarrenN
Copy link
Owner

DarrenN commented May 25, 2019

Ah yup I see the problem. Also realized there's no test for save-identikon which is why this wasn't caught. Will address both problems.

@DarrenN
Copy link
Owner

DarrenN commented May 25, 2019

@greghendershott went ahead and updated the contract to specify (or/c void? exn:fail?) and updated the docs. It's been merged, not sure how long before Racket's package system picks up the new version.

@DarrenN
Copy link
Owner

DarrenN commented May 25, 2019

@greghendershott I kicked off a package rescan, so:

The results will be available after the next index refresh, which is scheduled for Saturday, May 25th, 2019 7:44:25pm (UTC)

@greghendershott
Copy link
Contributor Author

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants