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

subtypes of restricted parametric types are unrestricted #148

Closed
StefanKarpinski opened this issue Jul 22, 2011 · 2 comments
Closed

subtypes of restricted parametric types are unrestricted #148

StefanKarpinski opened this issue Jul 22, 2011 · 2 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@StefanKarpinski
Copy link
Member

I can see that it would be annoying to enforce this, but it seems bad:

julia> abstract Pointy{T<:Real}

julia> type Point{T} <: Pointy{T}
         x::T
         y::T
       end

julia> Pointy{String}
type error: Pointy: in T, expected Real, got AbstractKind

julia> Point{String}
Point{String}

Can subtypes inherit restrictions on their type parameters from their supertype?

@ghost ghost assigned JeffBezanson Jul 22, 2011
@JeffBezanson
Copy link
Member

Yes, it should be an error to instantiate Pointy{T} in the definition of Point since T does not match Pointy's parameter.

@JeffBezanson
Copy link
Member

I think I decided that Pointy{T} is ok since people like to write things like Complex{T} in method signatures without worrying about it, but Point{String} should give an error. That's OK since it makes sense to say a method matches Pointy with any parameter type, even though you can only actually make Pointy instances with valid parameters <:Real.

StefanKarpinski pushed a commit that referenced this issue Feb 8, 2018
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Oct 11, 2021
Keno pushed a commit that referenced this issue Oct 9, 2023
vtjnash pushed a commit that referenced this issue Dec 8, 2023
Stdlib: Statistics
URL: https://github.com/JuliaStats/Statistics.jl.git
Stdlib branch: master
Julia branch: jn/loading-stdlib-exts
Old commit: 04e5d89
New commit: 68869af
Julia version: 1.11.0-DEV
Statistics version: 1.11.1(Does not match)
Bump invoked by: @vtjnash
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaStats/Statistics.jl@04e5d89...68869af

```
$ git log --oneline 04e5d89..68869af
68869af Bump patch for version 1.11.1
89f5fc7 Create tagbot.yml
dc844db CI: restore v1.9.4 to build matrix (#159)
d0523ae relax test for mapreduce_empty (#156)
d1c1c42 Drop support for v1.9 in CI (#157)
bfc6326 Fix `quantile` with `Date` and `DateTime` (#153)
b8ea3d2 Prevent overflow in `mean(::AbstractRange)` and relax type constraint. (#150)
a88ae4f Document MATLAB behavior in `quantile` docstring (#152)
46290a0 Revert "Prepare standalone package, step 2 (#128)" (#148)
81a90af make SparseArrays a weak dependency (#134)
```

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants