aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-06-14 16:21:57 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-06-14 16:31:46 +0100
commitb3090f174b35f764f609695e6d33f8c6765e24ab (patch)
tree1a957134b88b05baa3ae29c6545cfbb38cd5df8a
parentde454a17cf5f9cbd7e4af895174c82e4a6890c36 (diff)
downloadgcc-b3090f174b35f764f609695e6d33f8c6765e24ab.zip
gcc-b3090f174b35f764f609695e6d33f8c6765e24ab.tar.gz
gcc-b3090f174b35f764f609695e6d33f8c6765e24ab.tar.bz2
Add comment about modules and paths
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. Addresses: #432
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h
index 1838e35..5787531 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h
@@ -1097,8 +1097,10 @@ private:
{
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 ();
@@ -1147,6 +1149,25 @@ private:
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))
{