diff --git a/third_party/move/move-compiler-v2/src/plan_builder.rs b/third_party/move/move-compiler-v2/src/plan_builder.rs index 804ba329bd0a43..517671e977785e 100644 --- a/third_party/move/move-compiler-v2/src/plan_builder.rs +++ b/third_party/move/move-compiler-v2/src/plan_builder.rs @@ -505,10 +505,17 @@ fn convert_location(env: &GlobalEnv, attr: Attribute) -> Option { match value { AttributeValue::Name(id, opt_module_name, _sym) => { let vloc = env.get_node_loc(id); - convert_module_id(env, vloc, opt_module_name) + let module_id_opt = convert_module_id(env, vloc.clone(), opt_module_name); + if !_sym.display(env.symbol_pool()).to_string().is_empty() || module_id_opt.is_none() { + env.error_with_labels(&loc, "invalid attribute value", vec![( + vloc, + "Expected a module identifier, e.g. 'std::vector'".to_string(), + )]); + } + module_id_opt }, AttributeValue::Value(id, _val) => { - let vloc = env.get_node_loc(id); + let vloc: Loc = env.get_node_loc(id); env.error_with_labels(&loc, "invalid attribute value", vec![( vloc, "Expected a module identifier, e.g. 'std::vector'".to_string(), diff --git a/third_party/move/move-compiler-v2/tests/unit_test/test/other_failures_invalid_location.exp b/third_party/move/move-compiler-v2/tests/unit_test/test/other_failures_invalid_location.exp index 56976665006812..f756284238751f 100644 --- a/third_party/move/move-compiler-v2/tests/unit_test/test/other_failures_invalid_location.exp +++ b/third_party/move/move-compiler-v2/tests/unit_test/test/other_failures_invalid_location.exp @@ -30,6 +30,30 @@ error: Expected `location` following `major_status` 22 │ #[expected_failure(major_status=4016, minor_code=0)] │ ^^^^^^^^^^^^^^^^^ +error: invalid attribute value + ┌─ tests/unit_test/test/other_failures_invalid_location.move:26:38 + │ +26 │ #[expected_failure(vector_error, location=x)] + │ ^^^^^^^^^^ + │ │ + │ Expected a module identifier, e.g. 'std::vector' + +error: invalid attribute value + ┌─ tests/unit_test/test/other_failures_invalid_location.move:30:36 + │ +30 │ #[expected_failure(out_of_gas, location=0x1::m::t0)] + │ ^^^^^^^^^^^^^^^^^^^ + │ │ + │ Expected a module identifier, e.g. 'std::vector' + +error: invalid attribute value + ┌─ tests/unit_test/test/other_failures_invalid_location.move:34:43 + │ +34 │ #[expected_failure(major_status=4004, location=self)] + │ ^^^^^^^^^^^^^ + │ │ + │ Expected a module identifier, e.g. 'std::vector' + error: invalid attribute value ┌─ tests/unit_test/test/other_failures_invalid_location.move:38:59 │