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

DegreePlan() constructor - Warning: Method definition overwritten #112

Open
haydenfree opened this issue Mar 31, 2021 · 1 comment
Open
Labels
bug Something isn't working

Comments

@haydenfree
Copy link
Member

Dreaded warning:

WARNING: Method definition (::Type{CurricularAnalytics.DegreePlan})(AbstractString, CurricularAnalytics.Curriculum, Array{CurricularAnalytics.Term, 1}) in module CurricularAnalytics at /Users/hayden/.julia/packages/CurricularAnalytics/qqlQU/src/DataTypes/DegreePlan.jl:74 overwritten at /Users/hayden/.julia/packages/CurricularAnalytics/qqlQU/src/DataTypes/DegreePlan.jl:99.
  ** incremental compilation may be fatally broken for this module **

Below is an explanation of why. Fix needs to be implemented.

# assert type check, so check if 1+2 yields abstractfloat (does not)
julia> (1+2)::AbstractFloat
ERROR: TypeError: in typeassert, expected AbstractFloat, got a value of type Int64
Stacktrace:
 [1] top-level scope at REPL[3]:1

# yields an Int, of which number is a supertype, so it does yield a number
julia> (1+2)::Number
3

# A is a Course
julia> A = Course("A", 3, institution="ACME State", prefix="BW", num="101", canonical_name="Baskets I")
Course(2159971713, Dict{Int64,Int64}(), "A", 3, "BW", "101", "ACME State", "", "", Course[], "Baskets I", Dict{Int64,Requisite}(), LearningOutcome[], Dict{String,Any}(), Dict{String,Any}(), 0.5)

julia> supertypes(Course)
(Course, CurricularAnalytics.AbstractCourse, Any)

# A is an AbstractCourse since that's a supertype of Course
julia> (A)::CurricularAnalytics.AbstractCourse
Course(2159971713, Dict{Int64,Int64}(), "A", 3, "BW", "101", "ACME State", "", "", Course[], "Baskets I", Dict{Int64,Requisite}(), LearningOutcome[], Dict{String,Any}(), Dict{String,Any}(), 0.5)

# Create array with just A
julia> arr = [A]
1-element Array{Course,1}:
 Course(2159971713, Dict{Int64,Int64}(), "A", 3, "BW", "101", "ACME State", "", "", Course[], "Baskets I", Dict{Int64,Requisite}(), LearningOutcome[], Dict{String,Any}(), Dict{String,Any}(), 0.5)

# Array{Course,1} is not an Array of AbstractCourses.
julia> arr::Array{CurricularAnalytics.AbstractCourse,1}
ERROR: TypeError: in typeassert, expected Array{CurricularAnalytics.AbstractCourse,1}, got a value of type Array{Course,1}
Stacktrace:
 [1] top-level scope at REPL[19]:1

# However, using syntax Array{<:Integer} refers to all arrays whose element type is some kind of Integer

# Array{Course,1} is an array whose element is some type of AbstractCourse
julia> arr::Array{<:CurricularAnalytics.AbstractCourse,1}
1-element Array{Course,1}:
 Course(2159971713, Dict{Int64,Int64}(), "A", 3, "BW", "101", "ACME State", "", "", Course[], "Baskets I", Dict{Int64,Requisite}(), LearningOutcome[], Dict{String,Any}(), Dict{String,Any}(), 0.5)

# for sanity, show that an array of Int64 is not an array whose elements are some type of AbstractCourse.
julia> nums = [1,2,3]
3-element Array{Int64,1}:
 1
 2
 3

julia> nums::Array{<:CurricularAnalytics.AbstractCourse,1}
ERROR: TypeError: in typeassert, expected Array{var"#s3",1} where var"#s3"<:CurricularAnalytics.AbstractCourse, got a value of type Array{Int64,1}
Stacktrace:
 [1] top-level scope at REPL[22]:1
@haydenfree haydenfree added the bug Something isn't working label Mar 31, 2021
@heileman
Copy link
Contributor

Incredibly helpful - and it wins you a "Bridge prize." Fixed this warning in commit: 3cbe92c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants