Skip to content

Commit

Permalink
Fix the handling of equality constraints involving concrete types
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouko-taiga committed Aug 4, 2024
1 parent 50445c2 commit c48c53b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/FrontEnd/TypeChecking/TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2207,7 +2207,7 @@ struct TypeChecker {

// Rule orientation depends on ordering.
var v = buildTerm(a)
var u = b.isTypeParameter ? buildTerm(b) : v.appending(.concrete(b))
var u = buildTerm(b)

if let t = TraitDecl.ID(e.decl) {
v = v.substituting([.parameterType(program[t].receiver)], for: [.trait(t)])
Expand Down
20 changes: 20 additions & 0 deletions Tests/HyloTests/TestCases/TypeChecking/ConditionalExtension3.hylo
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//- typeCheck expecting: .failure

type Box<Contents: Regular> {
public var contents: Contents
public memberwise init
}

extension Box where Contents == Int {
public fun contains_zero() -> Bool {
contents == 0
}
}

public fun main() {
let b0 = Box(contents: true)
_ = b0.contains_zero() //! diagnostic reference to 'contains_zero' requires that 'Bool' be equal to 'Int'

let b1 = Box(contents: 1)
_ = b1.contains_zero()
}

0 comments on commit c48c53b

Please sign in to comment.