Skip to content

Commit

Permalink
Updated enum member literals to work with new type resolution system
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacShelton committed Oct 15, 2024
1 parent 682afcc commit f98e750
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/resolve/conform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn conform_expr<O: Objective>(
};

let Ok(to_type) = ctx.resolved_ast.unalias(to_type) else {
warn_type_alias_depth_exceeded(&expr.resolved_type);
warn_type_alias_depth_exceeded(to_type);
return O::fail();
};

Expand Down
21 changes: 7 additions & 14 deletions src/resolve/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,39 +358,32 @@ pub fn resolve_expr(
resolved::TypeKind::Boolean.at(source),
resolved::Expr::new(resolved::ExprKind::BooleanLiteral(*value), source),
)),
ast::ExprKind::EnumMemberLiteral(_enum_member_literal) => {
todo!("resolve enum member literal");

/*
let resolved_type = resolve_type(
ctx.type_search_ctx,
ast::ExprKind::EnumMemberLiteral(enum_member_literal) => {
let resolved_type = ctx.type_ctx().resolve(
&ast::TypeKind::Named(enum_member_literal.enum_name.clone())
.at(enum_member_literal.source),
&mut Default::default(),
)?;

let TypeKind::Enum(_, _) = &resolved_type.kind else {
let TypeKind::Enum(human_name, enum_ref) = &resolved_type.kind else {
return Err(ResolveErrorKind::StaticMemberOfTypeDoesNotExist {
ty: enum_member_literal.enum_name.to_string(),
member: enum_member_literal.variant_name.clone(),
}
.at(source));
};

let resolved_name = resolved_name.clone();
Ok(TypedExpr::new(
resolved_type,
resolved_type.clone(),
resolved::Expr::new(
resolved::ExprKind::EnumMemberLiteral(Box::new(resolved::EnumMemberLiteral {
enum_name: resolved_name,
human_name: human_name.clone(),
enum_ref: *enum_ref,
variant_name: enum_member_literal.variant_name.clone(),
source,
})),
source,
),
))
*/
))
}
ast::ExprKind::InterpreterSyscall(info) => {
let ast::InterpreterSyscall {
Expand Down
7 changes: 0 additions & 7 deletions src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ pub fn resolve<'a>(

let mut type_jobs = Vec::with_capacity(ast_workspace.files.len());

// Pre-resolve types for new type resolution system
for (physical_file_id, file) in ast_workspace.files.iter() {
let file_id = ast_workspace
.get_owning_module(*physical_file_id)
Expand Down Expand Up @@ -221,7 +220,6 @@ pub fn resolve<'a>(
}

// Create edges between types
#[allow(dead_code, unused_variables)]
for job in type_jobs.iter() {
let file = ast_workspace
.files
Expand All @@ -232,11 +230,6 @@ pub fn resolve<'a>(
.get_owning_module(job.physical_file_id)
.unwrap_or(job.physical_file_id);

let types = resolved_ast
.types_per_module
.entry(module_file_id)
.or_default();

for (structure_ref, structure) in job.structures.iter().zip(file.structures.iter()) {
for (field_name, field) in structure.fields.iter() {
let type_ctx = ResolveTypeCtx::new(
Expand Down

0 comments on commit f98e750

Please sign in to comment.