Fix wonky casting rules
This commit is contained in:
parent
de881d73d2
commit
5175878407
@ -63,6 +63,10 @@ namespace AST {
|
||||
std::shared_ptr<types::Type> ValueReferenceExpression::get_codegen_type(codegen::Scope& scope) {
|
||||
auto value = scope.values.find(this->m_name);
|
||||
if (value != scope.values.end()) {
|
||||
if (value->second.ty->m_kind == types::TypeKind::Pointer) {
|
||||
auto ptr_ty = dynamic_cast<types::PointerType*>(value->second.ty.get());
|
||||
return ptr_ty->m_inner;
|
||||
}
|
||||
return value->second.ty;
|
||||
}
|
||||
else {
|
||||
@ -167,10 +171,8 @@ namespace AST {
|
||||
|
||||
codegen::StackValue CastExpression::codegen(codegen::Builder& builder, codegen::Scope& scope) {
|
||||
auto expr_ty = this->m_expr->get_codegen_type(scope);
|
||||
if ((expr_ty->m_kind == types::TypeKind::Array
|
||||
|| expr_ty->m_kind == types::TypeKind::Pointer)
|
||||
if (expr_ty->m_kind == types::TypeKind::Array
|
||||
&& this->m_ty->m_kind == types::TypeKind::Pointer) {
|
||||
std::cout << expr_ty->formatted() << std::endl;
|
||||
auto lvalued = scope.with_lvalue();
|
||||
auto expr = this->m_expr->codegen(builder, lvalued);
|
||||
auto cast = types::find_cast(scope.casts, expr.ty, this->m_ty);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user