Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rahxephon89 committed Jul 2, 2024
1 parent 0a599a2 commit 0f35b80
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 44 deletions.
66 changes: 33 additions & 33 deletions third_party/move/move-compiler-v2/tests/checking-lang-v1/index.exp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ error: unsupported language construct
│ ^^^^^^^^^^^^^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:16:19
┌─ tests/checking-lang-v1/index.move:16:17
16 │ assert!((&R[@0x1]).value == false, 1);
^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
16 │ assert!(R[@0x1].value == false, 1);
│ ^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:38:19
┌─ tests/checking-lang-v1/index.move:38:17
38 │ assert!((&test::Y<X<bool>>[@0x1]).field.value == true, 0);
^^^^^^^^^^^^^^^^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
38 │ assert!(test::Y<X<bool>>[@0x1].field.value == true, 0);
│ ^^^^^^^^^^^^^^^^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:43:22
Expand All @@ -31,10 +31,10 @@ error: unsupported language construct
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:45:19
┌─ tests/checking-lang-v1/index.move:45:17
45 │ assert!((&Y<X<bool>>[addr]) .field.value == false, 1);
^^^^^^^^^^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
45 │ assert!(Y<X<bool>>[addr].field.value == false, 1);
│ ^^^^^^^^^^^^^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:53:17
Expand All @@ -43,49 +43,49 @@ error: unsupported language construct
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:70:19
┌─ tests/checking-lang-v1/index.move:70:17
70 │ assert!((&v[0]).field.value == true, 0);
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
70 │ assert!(v[0].field.value == true, 0);
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:71:19
┌─ tests/checking-lang-v1/index.move:71:17
71 │ assert!((&v[1]).field.value == false, 0);
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
71 │ assert!(v[1].field.value == false, 0);
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:88:19
┌─ tests/checking-lang-v1/index.move:88:17
88 │ assert!((&v[0]).field.value == true, 0);
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
88 │ assert!(v[0].field.value == true, 0);
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:89:19
┌─ tests/checking-lang-v1/index.move:89:17
89 │ assert!((&v[1]).field.value == false, 0);
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
89 │ assert!(v[1].field.value == false, 0);
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:90:15
┌─ tests/checking-lang-v1/index.move:90:9
90 │ (&mut v[0]).field.value = false;
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
90 │ v[0].field.value = false;
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:91:15
┌─ tests/checking-lang-v1/index.move:91:9
91 │ (&mut v[1]).field.value = true;
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
91 │ v[1].field.value = true;
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:92:19
┌─ tests/checking-lang-v1/index.move:92:17
92 │ assert!((&v[0]).field.value == false, 0);
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
92 │ assert!(v[0].field.value == false, 0);
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2

error: unsupported language construct
┌─ tests/checking-lang-v1/index.move:93:19
┌─ tests/checking-lang-v1/index.move:93:17
93 │ assert!((&v[1]).field.value == true, 0);
^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
93 │ assert!(v[1].field.value == true, 0);
│ ^^^^ `_[_]` index operator in non-specification code only allowed in Move 2
22 changes: 11 additions & 11 deletions third_party/move/move-compiler-v2/tests/checking-lang-v1/index.move
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module 0x42::test {

fun test_resource_2() acquires R {
0x42::test::R[@0x1].value = false;
assert!((&R[@0x1]).value == false, 1);
assert!(R[@0x1].value == false, 1);
}

struct X<M> has copy, drop, store {
Expand All @@ -35,14 +35,14 @@ module 0x42::test {

fun test_resource_3() {
use 0x42::test;
assert!((&test::Y<X<bool>>[@0x1]).field.value == true, 0);
assert!(test::Y<X<bool>>[@0x1].field.value == true, 0);
}

fun test_resource_4() {
let addr = @0x1;
let y = &mut 0x42::test ::Y<X<bool>> [addr];
y.field.value = false;
assert!((&Y<X<bool>>[addr]) .field.value == false, 1);
assert!(Y<X<bool>>[addr].field.value == false, 1);
}

fun test_vector() {
Expand All @@ -67,8 +67,8 @@ module 0x42::test {
field: x2
};
let v = vector[y1, y2];
assert!((&v[0]).field.value == true, 0);
assert!((&v[1]).field.value == false, 0);
assert!(v[0].field.value == true, 0);
assert!(v[1].field.value == false, 0);
}

fun test_vector_borrow_mut() {
Expand All @@ -85,12 +85,12 @@ module 0x42::test {
field: x2
};
let v = vector[y1, y2];
assert!((&v[0]).field.value == true, 0);
assert!((&v[1]).field.value == false, 0);
(&mut v[0]).field.value = false;
(&mut v[1]).field.value = true;
assert!((&v[0]).field.value == false, 0);
assert!((&v[1]).field.value == true, 0);
assert!(v[0].field.value == true, 0);
assert!(v[1].field.value == false, 0);
v[0].field.value = false;
v[1].field.value = true;
assert!(v[0].field.value == false, 0);
assert!(v[1].field.value == true, 0);
}


Expand Down
2 changes: 2 additions & 0 deletions third_party/move/move-model/src/builder/exp_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3470,6 +3470,8 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo
}
if !self.is_spec_mode() {
self.check_language_version(loc, "vector indexing", LanguageVersion::V2_0);
// Translate to vector indexing in impl mode if the target is not a resource or a spec schema
// spec mode is handled in `translate_index`
if call.is_none() {
call =
Some(self.call_to_vector_borrow_for_index_op(
Expand Down

0 comments on commit 0f35b80

Please sign in to comment.