diff --git a/Sources/FrontEnd/TypeChecking/TypeChecker.swift b/Sources/FrontEnd/TypeChecking/TypeChecker.swift index 1d0c5d102..241f34c57 100644 --- a/Sources/FrontEnd/TypeChecking/TypeChecker.swift +++ b/Sources/FrontEnd/TypeChecking/TypeChecker.swift @@ -3692,7 +3692,7 @@ struct TypeChecker { _ = inferredType(of: program[e].left, updating: &obligations) case .up: - // The type of thr LHS must be statically known to subtype of the RHS. + // The type of the 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)) diff --git a/Sources/IR/Analysis/Lifetime.swift b/Sources/IR/Analysis/Lifetime.swift index 6844c92c8..1b5602779 100644 --- a/Sources/IR/Analysis/Lifetime.swift +++ b/Sources/IR/Analysis/Lifetime.swift @@ -193,7 +193,7 @@ extension Module { case (.closed(let lhs), .liveIn(let rhs)): return .liveIn(lastUse: last(lhs, rhs)) case (.closed(let lhs), .closed(let rhs)): - return .liveIn(lastUse: last(lhs, rhs)) + return .closed(lastUse: last(lhs, rhs)) } } return .init(operand: left.operand, coverage: coverage) diff --git a/Sources/IR/Emitter.swift b/Sources/IR/Emitter.swift index 758ad44b1..5484d7f0e 100644 --- a/Sources/IR/Emitter.swift +++ b/Sources/IR/Emitter.swift @@ -2082,10 +2082,24 @@ struct Emitter { /// Inserts the IR for lvalue `e`. private mutating func emitLValue(_ e: CastExpr.ID) -> Operand { switch ast[e].direction { + case .up: + return emitLValue(upcast: e) case .pointerConversion: return emitLValue(pointerConversion: e) default: - UNIMPLEMENTED() + UNIMPLEMENTED("lvalue lowering for cast expressions #1049") + } + } + + /// Inserts the IR for lvalue `e`. + private mutating func emitLValue(upcast e: CastExpr.ID) -> Operand { + switch ast[e].left.kind { + case FloatLiteralExpr.self: + return emitStore(value: ast[e].left) + case IntegerLiteralExpr.self: + return emitStore(value: ast[e].left) + default: + UNIMPLEMENTED("lvalue lowering for cast expressions #1049") } } diff --git a/Tests/HyloTests/TestCases/Lowering/NumericLiteral.hylo b/Tests/HyloTests/TestCases/Lowering/NumericLiteral.hylo index 2c0ad08ff..88277275d 100644 --- a/Tests/HyloTests/TestCases/Lowering/NumericLiteral.hylo +++ b/Tests/HyloTests/TestCases/Lowering/NumericLiteral.hylo @@ -17,4 +17,7 @@ public fun main() { let _: Float32 = 1 let _: Float32 = 1.0 + + let _ = 1 as Int8 + let _ = 1 as Float64 }