Skip to content

Commit

Permalink
Change how import works.
Browse files Browse the repository at this point in the history
spaces
  • Loading branch information
Kris Brown committed Dec 7, 2024
1 parent f1fe523 commit 5eb1352
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/models/ModelInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,7 @@ function typecheck_instance(

overload_errormsg =
"the types for this model declaration do not permit Julia overloading to distinguish between GAT overloads"

for (decl, resolver) in theory.resolvers
if nameof(decl) ext_functions
continue
end
for (_, x) in allmethods(resolver)
if getvalue(theory[x]) isa AlgStruct
continue
Expand Down Expand Up @@ -455,6 +451,7 @@ function typecheck_instance(
end

for (sig, (decl, method)) in undefined_signatures
nameof(decl) ext_functions && continue # assume it has been impl'd already
judgment = getvalue(theory[method])
if judgment isa AlgTermConstructor
error("Failed to implement $decl: $(toexpr(sig))")
Expand Down
26 changes: 26 additions & 0 deletions test/models/ModelInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,30 @@ end
munit() = 0
end

# Test scenario where we @import a method but then extend it
############################################################
@theory T1 begin
X::TYPE;
h(a::X)::X
end

@theory T2<:T1 begin
Y::TYPE;
h(b::Y)::Y
end

@instance T1{Int} begin
h(a::Int) = 1
end

@instance T2{Int,Bool} begin
@import X, h
h(b::Bool) = false
end

@test h(2) == 1

@test h(false) == false


end # module

0 comments on commit 5eb1352

Please sign in to comment.