ast.table: fix aggregate field type equality check (#11210)
							parent
							
								
									eee71cebd4
								
							
						
					
					
						commit
						d2ce1f74d6
					
				| 
						 | 
					@ -412,9 +412,14 @@ fn (t &Table) register_aggregate_field(mut sym TypeSymbol, name string) ?StructF
 | 
				
			||||||
			if !found_once {
 | 
								if !found_once {
 | 
				
			||||||
				found_once = true
 | 
									found_once = true
 | 
				
			||||||
				new_field = type_field
 | 
									new_field = type_field
 | 
				
			||||||
			} else if !new_field.equals(type_field) {
 | 
								} else if new_field.typ != type_field.typ {
 | 
				
			||||||
				return error('field `${t.type_to_str(typ)}.$name` type is different')
 | 
									return error('field `${t.type_to_str(typ)}.$name` type is different')
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								new_field = StructField{
 | 
				
			||||||
 | 
									...new_field
 | 
				
			||||||
 | 
									is_mut: new_field.is_mut && type_field.is_mut
 | 
				
			||||||
 | 
									is_pub: new_field.is_pub && type_field.is_pub
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return error('type `${t.type_to_str(typ)}` has no field or method `$name`')
 | 
								return error('type `${t.type_to_str(typ)}` has no field or method `$name`')
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -193,7 +193,9 @@ fn (a Alfa) letter() rune {
 | 
				
			||||||
struct Bravo {
 | 
					struct Bravo {
 | 
				
			||||||
	// A field so that Alfa and Bravo structures aren't the same
 | 
						// A field so that Alfa and Bravo structures aren't the same
 | 
				
			||||||
	dummy_field int
 | 
						dummy_field int
 | 
				
			||||||
	char        rune = `b`
 | 
					pub mut:
 | 
				
			||||||
 | 
						// NB: the `char` field is not `pub` or `mut` in all sumtype variants, but using it in aggregates should still work
 | 
				
			||||||
 | 
						char rune = `b`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn (b Bravo) letter() rune {
 | 
					fn (b Bravo) letter() rune {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue