parser: `mut x Type` syntax for args
							parent
							
								
									61e00e6796
								
							
						
					
					
						commit
						99cf520bd4
					
				|  | @ -358,16 +358,20 @@ fn (mut p Parser) fn_args() ([]table.Arg, bool) { | |||
| 		} | ||||
| 	} else { | ||||
| 		for p.tok.kind != .rpar { | ||||
| 			mut is_mut := p.tok.kind == .key_mut | ||||
| 			if is_mut { | ||||
| 				p.next() | ||||
| 			} | ||||
| 			mut arg_names := [p.check_name()] | ||||
| 			// `a, b, c int`
 | ||||
| 			for p.tok.kind == .comma { | ||||
| 				p.check(.comma) | ||||
| 				arg_names << p.check_name() | ||||
| 			} | ||||
| 			is_mut := p.tok.kind == .key_mut | ||||
| 			// if is_mut {
 | ||||
| 			// p.check(.key_mut)
 | ||||
| 			// }
 | ||||
| 			if p.tok.kind == .key_mut { | ||||
| 				// TODO remove old syntax
 | ||||
| 				is_mut = true | ||||
| 			} | ||||
| 			if p.tok.kind == .ellipsis { | ||||
| 				p.check(.ellipsis) | ||||
| 				is_variadic = true | ||||
|  |  | |||
|  | @ -65,6 +65,14 @@ fn modify_array(a mut []int) { | |||
| 	// a << 888
 | ||||
| } | ||||
| 
 | ||||
| fn modify_array2(mut a []int) { | ||||
| 	a[0] = 10 | ||||
| 	for i in 0 .. a.len { | ||||
| 		a[i] = a[i] * 2 | ||||
| 	} | ||||
| 	// a << 888
 | ||||
| } | ||||
| 
 | ||||
| fn test_mut_array() { | ||||
| 	mut nums := [1, 2, 3] | ||||
| 	modify_array(mut nums) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue