Fixed error message for types in match exprs not being unions
This commit is contained in:
		
							parent
							
								
									78ea6e45b2
								
							
						
					
					
						commit
						eb2c1c8aed
					
				| @ -68,7 +68,7 @@ U: (| Int F64) | ||||
| 
 | ||||
| func TestMatchErrNotUnion (test *testing.T) { | ||||
| testStringErr (test, | ||||
| "type U is not a union", 3, 24, | ||||
| "type U is not a union", 3, 30, | ||||
| ` | ||||
| U: Int | ||||
| [matchToInt u:U]:Int = match u | ||||
|  | ||||
| @ -549,7 +549,7 @@ func (this *Tree) analyzeOperation ( | ||||
| 		 | ||||
| 	case entity.OperatorLeftShift, entity.OperatorRightShift: | ||||
| 		if len(operation.Arguments) != 2 { return wrongArgCount() } | ||||
| 		if !isInteger(into)         { return wrongInto()     } | ||||
| 		if !isInteger(into)              { return wrongInto()     } | ||||
| 
 | ||||
| 		arg, err := this.analyzeExpression(into, mode, operation.Arguments[0]) | ||||
| 		if err != nil { return nil, err } | ||||
| @ -594,7 +594,8 @@ func (this *Tree) analyzeBlock ( | ||||
| 
 | ||||
| 	if len(block.Steps) == 0 && into != nil { | ||||
| 		return nil, errors.Errorf ( | ||||
| 			block.Position(), "block must have at least one statement") | ||||
| 			block.Position(), | ||||
| 			"block must have at least one statement") | ||||
| 	} | ||||
| 
 | ||||
| 	final := len(block.Steps) - 1 | ||||
| @ -603,7 +604,8 @@ func (this *Tree) analyzeBlock ( | ||||
| 			expression, ok := step.(entity.Expression) | ||||
| 			if !ok { | ||||
| 				return nil, errors.Errorf ( | ||||
| 					block.Position(), "expected expression") | ||||
| 					block.Position(), | ||||
| 					"expected expression") | ||||
| 			} | ||||
| 			 | ||||
| 			step, err := this.analyzeExpression(into, strict, expression) | ||||
| @ -642,14 +644,16 @@ func (this *Tree) analyzeMemberAccess ( | ||||
| 		referenced, ok := ReduceToBase(sourceTypeAny.Referenced).(*entity.TypeStruct) | ||||
| 		if !ok { | ||||
| 			return nil, errors.Errorf ( | ||||
| 				access.Position(), "cannot access members of %v", | ||||
| 				access.Position(), | ||||
| 				"cannot access members of %v", | ||||
| 				source) | ||||
| 		} | ||||
| 		sourceType          = referenced | ||||
| 		qualifiedSourceType = sourceTypeAny.Referenced | ||||
| 	default: | ||||
| 		return nil, errors.Errorf ( | ||||
| 			access.Position(), "cannot access members of %v", | ||||
| 			access.Position(), | ||||
| 			"cannot access members of %v", | ||||
| 			source) | ||||
| 	} | ||||
| 
 | ||||
| @ -723,10 +727,8 @@ func (this *Tree) analyzeMatch ( | ||||
| 	match.Value = value | ||||
| 	rawUnion, ok := this.isUnion(value.Type()) | ||||
| 	if !ok { | ||||
| 		// FIXME: add Position() method to Expression, then change this | ||||
| 		// error message (and others) #53 | ||||
| 		return nil, errors.Errorf ( | ||||
| 			match.Position(), "type %v is not a union", | ||||
| 			match.Value.Position(), "type %v is not a union", | ||||
| 			value.Type()) | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user