Skip to content

Commit

Permalink
Add comment about modules and paths
Browse files Browse the repository at this point in the history
In order to support modules the path expression will fail here since a
module is not a value and does not have a TyTy type, so this is ok to
continue the rest of resolution so long as there are more segments.
  • Loading branch information
philberty committed Jun 14, 2021
1 parent 4259525 commit 9eaaec4
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion gcc/rust/typecheck/rust-hir-type-check-expr.h
Expand Up @@ -1097,8 +1097,10 @@ class TypeCheckExpr : public TypeCheckBase
{
TyTy::BaseType *root_tyty = nullptr;
*offset = 0;
for (auto &seg : expr.get_segments ())
for (size_t i = 0; i < expr.get_num_segments (); i++)
{
HIR::PathExprSegment &seg = expr.get_segments ().at (i);
bool have_more_segments = i < expr.get_num_segments ();
bool is_root = *offset == 0;
NodeId ast_node_id = seg.get_mappings ().get_nodeid ();

Expand Down Expand Up @@ -1147,6 +1149,25 @@ class TypeCheckExpr : public TypeCheckBase
return root_tyty;
}

// FIXME
// modules are not going to have an explicit TyTy.In this case we
// can probably do some kind of check. By looking up if the HirId ref
// node is a module and continue. If the path expression is single
// segment of module we can error with expected value but found module
// or something.
//
// Something like this
//
// bool seg_is_module = mappings->lookup_module (ref);
// if (seg_is_module)
// {
// if (have_more_segments)
// continue;
//
// rust_error_at (seg.get_locus (), "expected value");
// return new TyTy::ErrorType (expr.get_mappings ().get_hirid ());
// }

TyTy::BaseType *lookup = nullptr;
if (!context->lookup_type (ref, &lookup))
{
Expand Down

0 comments on commit 9eaaec4

Please sign in to comment.