tests: fix a match test
							parent
							
								
									12d66208b8
								
							
						
					
					
						commit
						c5aa2bfa51
					
				|  | @ -149,6 +149,10 @@ fn (mut c Checker) check_shift(left_type, right_type table.Type, left_pos, right | |||
| 		if sym.kind == .alias && (sym.info as table.Alias).parent_type.is_int() { | ||||
| 			return left_type | ||||
| 		} | ||||
| 		if c.pref.translated && left_type == table.bool_type { | ||||
| 			// allow `bool << 2` in translated C code
 | ||||
| 			return table.int_type | ||||
| 		} | ||||
| 		c.error('invalid operation: shift of type `$sym.name`', left_pos) | ||||
| 		return table.void_type | ||||
| 	} else if !right_type.is_int() { | ||||
|  |  | |||
|  | @ -1731,6 +1731,7 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { | |||
| 		} | ||||
| 		if c.pref.translated { | ||||
| 			// TODO fix this in C2V instead, for example cast enums to int before using `|` on them.
 | ||||
| 			// TODO replace all c.pref.translated checks with `$if !translated` for performance
 | ||||
| 			continue | ||||
| 		} | ||||
| 		// Single side check
 | ||||
|  | @ -3135,6 +3136,11 @@ pub fn (mut c Checker) enum_val(mut node ast.EnumVal) table.Type { | |||
| 		return table.void_type | ||||
| 	} | ||||
| 	mut typ := table.new_type(typ_idx) | ||||
| 	if c.pref.translated { | ||||
| 		// TODO make more strict
 | ||||
| 		node.typ = typ | ||||
| 		return typ | ||||
| 	} | ||||
| 	if typ == table.void_type { | ||||
| 		c.error('not an enum', node.pos) | ||||
| 		return table.void_type | ||||
|  | @ -3146,7 +3152,8 @@ pub fn (mut c Checker) enum_val(mut node ast.EnumVal) table.Type { | |||
| 		typ = array_info.elem_type | ||||
| 		typ_sym = c.table.get_type_symbol(typ) | ||||
| 	} | ||||
| 	if typ_sym.kind != .enum_ { | ||||
| 	if typ_sym.kind != .enum_ && !c.pref.translated { | ||||
| 		// TODO in C int fields can be compared to enums, need to handle that in C2V
 | ||||
| 		c.error('expected type is not an enum (`$typ_sym.name`)', node.pos) | ||||
| 		return table.void_type | ||||
| 	} | ||||
|  | @ -3220,6 +3227,10 @@ pub fn (mut c Checker) warn(s string, pos token.Position) { | |||
| } | ||||
| 
 | ||||
| pub fn (mut c Checker) error(message string, pos token.Position) { | ||||
| 	if c.pref.translated && message.starts_with('mismatched types') { | ||||
| 		// TODO move this
 | ||||
| 		return | ||||
| 	} | ||||
| 	if c.pref.is_verbose { | ||||
| 		print_backtrace() | ||||
| 	} | ||||
|  |  | |||
|  | @ -31,11 +31,11 @@ fn main() { | |||
| 		string { | ||||
| 			'string' | ||||
| 		} | ||||
| 		else { | ||||
| 			'else' | ||||
| 		} | ||||
| 		f64 { | ||||
| 			'f64' | ||||
| 		} | ||||
| 		else { | ||||
| 			'else' | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -559,6 +559,9 @@ fn (mut p Parser) check_fn_atomic_arguments(typ table.Type, pos token.Position) | |||
| } | ||||
| 
 | ||||
| fn (mut p Parser) fn_redefinition_error(name string) { | ||||
| 	if p.pref.translated { | ||||
| 		return | ||||
| 	} | ||||
| 	// Find where this function was already declared
 | ||||
| 	// TODO
 | ||||
| 	/* | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue