Skip to content

Value Type Update Issues #78

Description

@tk-codes

Since array, struct and map are value types, the following syntax does not work.

Map

Map<char, Person> map
map['a'] = new Person(1000)

// override value
map['a'].balance = 1001
// --> map['a'] returns a copy of the struct. Changing the value will not update the map.

Struct

struct Person{
   int[] nums
}

Person p = new Person(nums = new int[2])
p.nums[0] = 1
// --> p.nums returns a copy of the array. Changes on array will not be updated on struct.

Array

Person[] p = new Person[2]
p[0] = new Person(100)

p[0].balance = 101
// --> p[0] returns a copy of the struct. Changes will not take effect.

Once VM supports reference types (bazo-blockchain/bazo-vm#28), update the compiler and test them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions