Skip to content

Commit

Permalink
Merge pull request #1057 from hylo-lang/fix-literal-inference
Browse files Browse the repository at this point in the history
Fix type inference for numeric literals
  • Loading branch information
kyouko-taiga authored Oct 3, 2023
2 parents 738ec9d + ea99094 commit 12c55bf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/FrontEnd/TypeChecking/TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3687,18 +3687,18 @@ struct TypeChecker {

switch program[e].direction {
case .down:
// Note: constraining the type of the left operand to be above the right operand wouldn't
// contribute any useful information to the constraint system.
// Note: constraining the type of the LHS to be above the RHS wouldn't contribute any useful
// information to the constraint system.
_ = inferredType(of: program[e].left, updating: &obligations)

case .up:
// The type of the left operand must be statically known to subtype of the right operand.
// The type of thr LHS must be statically known to subtype of the RHS.
let lhs = inferredType(
of: program[e].left, withHint: ^freshVariable(), updating: &obligations)
obligations.insert(SubtypingConstraint(lhs, rhs.shape, origin: cause))

case .pointerConversion:
// The left operand must be a `Builtin.ptr`. The right operand must be a remote type.
// The LHS be a `Builtin.ptr`. The RHS must be a remote type.
if !(rhs.shape.base is RemoteType) {
report(.error(invalidPointerConversionAt: program[e].right.site))
return constrain(e, to: .error, in: &obligations)
Expand Down Expand Up @@ -3977,7 +3977,7 @@ struct TypeChecker {
case .infix(let callee, let lhs, let rhs):
// Infer the types of the operands.
let lhsType = _inferredType(of: lhs, updating: &obligations)
let rhsType = _inferredType(of: rhs, updating: &obligations)
let rhsType = _inferredType(of: rhs, withHint: ^freshVariable(), updating: &obligations)

if lhsType.isError || rhsType.isError {
return .error
Expand Down

0 comments on commit 12c55bf

Please sign in to comment.