-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Type-stabilize eachline #20356
Type-stabilize eachline #20356
Conversation
Why is the typeassert needed? Is this an inference bug, or could the |
|
@stevengj It seems that the problem is simply with type constructors with keyword arguments type Foo
i::Int
b::Bool
Foo(i::Int=1, b::Bool=true) = new(i, b)
end
type Bar
i::Int
b::Bool
Bar(i::Int=1; b::Bool=true) = new(i, b)
end
@code_warntype Foo(1)
# ...
end::Foo
@code_warntype Bar(1)
# ...
end::Any This PRs works around that in case there is no easy/soon-to-be fix. |
Another way to fix this is to change the EDIT: Added a second commit with the other possible solution. |
3954f52
to
f9e4db9
Compare
Well, that the return type of the constructors with keyword arguments cannot be inferred is rather unfortunate (do we an issue for that?), but with that explanation, just type-asserting their usages seems to be a valid work-around. |
Since people are supposed to use |
f9e4db9
to
ef29f00
Compare
We export |
Unfortunate as it may be that we can't type infer constructors with keyword arguments at the moment, that will be fixed and those type assertions can be deleted without affecting anyone's code. Committing to a public API based on a temporary performance issue is not a good move. |
|
In any case, let's leave this PR as the simplest fix that addresses the type issue: sticking some type annotations on calls to the |
ef29f00
to
a21a62e
Compare
I left just the type-assertion work-around, so the changes on the type constructor and unexporting can be done separately. |
A bit late now, but I guess we could just have made the constructor an outer constructor, replacing the |
Fix #20351