Weird Constructor Parameter Problem

julia> abstract type Environment end

julia> abstract type SymTable{mutability} <: Environment end

julia> mutable struct BigSymTable{M<:Bool} <: SymTable{M}
               BigSymTable{M}(dict::Dict{Symbol,T} = Dict{Symbol,Any}()) where T where M = new{M}(dict)

julia> BigSymTable{false}()
ERROR: TypeError: BigSymTable: in M, expected M<:Bool, got Bool

What is wrong with this picture?


false (a value) is not a subtype of Bool (a type) and thus false <: Bool fails. You can drop the <: Bool part and it should be fine.


Arguments to type parameters need to be types, not instances of types:


That’s definitely common, but it doesn’t have to be the case. For example, in Array{Int, 2} the 2 is a value, not a type. Likewise in the OP’s case, BigSymTable{false} is a perfectly reasonable type parameter.


You’re right. Sorry for the misinformation.