Skip to content
Snippets Groups Projects
  • Per Hedbor's avatar
    0aeaca58
    Fixed support for automap in assignments. · 0aeaca58
    Per Hedbor authored
    This was handled in a somewhat so-so manner in += and friends.
    
    Specifically, it ignored the [*] on the LHS and just assigned the
    variable to the result of the automap.
    
    So, x[*]+=10; was transformed to x = x[*] + 10;
    
    It also only worked for += with friends, not =, so x[*] = x[*] + 1 did
    not work.
    
    Now a new opcode is used that assigns array elements individually.
    This means that this works:
    
    |  array x = ({1,2,3});
    |  array y = x;
    |
    |  x[*] += 10;
    |  x==y; // will now be true, was previously false.
    
    Of course, this actually changes how automap works.
    
    The assignment is currently only done on the toplevel, x[*][*] =
    x[*][*]+1 still works just fine, but it has some similarities with the
    previous situation, the arrays in the toplevel array will be swapped,
    not altered.
    
    this will be fixed soonish(tm)
    0aeaca58
    History
    Fixed support for automap in assignments.
    Per Hedbor authored
    This was handled in a somewhat so-so manner in += and friends.
    
    Specifically, it ignored the [*] on the LHS and just assigned the
    variable to the result of the automap.
    
    So, x[*]+=10; was transformed to x = x[*] + 10;
    
    It also only worked for += with friends, not =, so x[*] = x[*] + 1 did
    not work.
    
    Now a new opcode is used that assigns array elements individually.
    This means that this works:
    
    |  array x = ({1,2,3});
    |  array y = x;
    |
    |  x[*] += 10;
    |  x==y; // will now be true, was previously false.
    
    Of course, this actually changes how automap works.
    
    The assignment is currently only done on the toplevel, x[*][*] =
    x[*][*]+1 still works just fine, but it has some similarities with the
    previous situation, the arrays in the toplevel array will be swapped,
    not altered.
    
    this will be fixed soonish(tm)