Skip to content

Conversation

@RX14
Copy link
Member

@RX14 RX14 commented Oct 15, 2017

See RX14/multipart.cr#7.

field could be passed an integer, which meant the incorrect IO::Memory.new overload was chosen. I chose to fix this by calling to_s on the result, but we could also make this more explicit by restricting to an IO.

# Content-Disposition header for the form part. Other headers can be added
# using *headers*.
def file(name, io, metadata : FileMetadata = FileMetadata.new, headers : HTTP::Headers = HTTP::Headers.new)
def file(name : String, io, metadata : FileMetadata = FileMetadata.new, headers : HTTP::Headers = HTTP::Headers.new)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not also restrict io : IO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, if not putting a type restriction led to a bug, we should always put type restrictions when possible.

@asterite asterite added this to the Next milestone Oct 19, 2017
@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Oct 19, 2017
@asterite asterite merged commit f414e74 into crystal-lang:master Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants