@[test(code_01)] invar x = 123 x += 1 @[test(code_01)] @[test(code_01)] {{At line}} .* {{Constant or invariable cannot be modified}} @[test(code_01)] @[test(code_01)] invar x = 123 var y = x y += 100 io.writeln( x, y ) @[test(code_01)] @[test(code_01)] 123 223 @[test(code_01)] @[test(code_01)] routine test100() { invar x = 123 var y = x y += 100 io.writeln( x, y ) } test100() @[test(code_01)] @[test(code_01)] 123 223 @[test(code_01)] @[test(code_01)] var x = 123 invar y = x x += 1 io.writeln( y ) @[test(code_01)] @[test(code_01)] 123 @[test(code_01)] @[test(code_01)] var x = { 1, 2, 3 } invar y = x x.append( 4 ) io.writeln( y ) @[test(code_01)] @[test(code_01)] { 1, 2, 3, 4 } @[test(code_01)] @[test(code_01)] routine f(invar x: @T>){} f( {} ) @[test(code_01)] @[test(code_01)] @[test(code_01)] @[test(code_01)] routine f(invar x: @T>){} invar ls: list = {}; f(ls) @[test(code_01)] @[test(code_01)] @[test(code_01)] @[test(code_01)] var x = { 1, 2, 3 } invar y = x y.append( 4 ) @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Invalid parameter type --- " 'invar>' for 'self:list' "}} @[test(code_01)] @[test(code_01)] invar x = { {1, 2}, {3, 4} } x[0].append( 5 ) @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Invalid parameter type --- " 'invar>' for 'self:list' "}} @[test(code_01)] @[test(code_01)] invar x = { {1, 2}, {3, 4} } y = x[0] y.append( 5 ) @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Invalid parameter type --- " 'invar>' for 'self:list' "}} @[test(code_01)] @[test(code_01)] invar x = { {1, 2}, {3, 4} } var y = x[0] y.append( 5 ) @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Invalid assignment from invar value to var varaible}} @[test(code_01)] @[test(code_01)] routine test200() { invar x = { {1, 2}, {3, 4} } var y = x[0] y.append( 5 ) } @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Invalid assignment from invar value to var varaible}} @[test(code_01)] @[test(code_01)] invar x = { {1, 2}, {3, 4} } var y = none y = x[0] y.append( 5 ) @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Types not matching --- " 'invar>' for 'var' "}} @[test(code_01)] @[test(code_01)] invar x: var = 123 @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid declaration}} @[test(code_01)] @[test(code_01)] var x: invar = 123 @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid declaration}} @[test(code_01)] @[test(code_01)] var m: map,int> = { $A -> 1, $B -> 2, $C -> 3 } invar k = $A io.writeln( m.find( k ) ) @[test(code_01)] @[test(code_01)] ( $A(0), 1 ) @[test(code_01)] @[test(code_01)] invar m: map,int> = { $A -> 1, $B -> 2, $C -> 3 } var k = $A io.writeln( m.find( k ) ) @[test(code_01)] @[test(code_01)] ( $A(0), 1 ) @[test(code_01)] @[test(code_01)] routine Test( invar par: list ) { par.append( 123 ) } @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Invalid parameter type --- " 'invar>' for 'self:list' "}} @[test(code_01)] @[test(code_01)] routine Test( invar par: list ) { par[0] += 123 } @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Constant or invariable cannot be modified}} @[test(code_01)] @[test(code_01)] routine Test( par: list ) { par.append( 123 ) } invar ls = { 1, 2 } Test( ls ) @[test(code_01)] @[test(code_01)] {{At line}} .* {{Invalid virtual machine instruction}} .* {{Invalid parameter type --- " 'invar>' for 'list' "}} @[test(code_01)] @[test(code_01)] type Tuple = tuple, name: invar> tup: Tuple = ( 123, 'abc' ) tup.index = 456 @[test(code_01)] @[test(code_01)] {{At line}} .* {{Constant or invariable cannot be modified}} @[test(code_01)] @[test(code_01)] invar a = { 1 } b = (any) a b.append( 2 ) io.writeln( std.about(a) != std.about(b) ) @[test(code_01)] @[test(code_01)] true @[test(code_01)] # Covariant to invariable containers: @[test(code_01)] var a = { 1 }; var b = { 1=>2 }; invar c: list = a; invar d: list = a; invar e: map = b; @[test(code_01)] @[test(code_01)] @[test(code_01)]