Fix float coersion rules
This commit is contained in:
		
							parent
							
								
									a1507e14ca
								
							
						
					
					
						commit
						ec0c7fa194
					
				| @ -457,6 +457,20 @@ impl Collapsable for TypeKind { | ||||
|                     _ => Err(ErrorKind::TypesIncompatible(self.clone(), other.clone())), | ||||
|                 } | ||||
|             } | ||||
|             (TypeKind::Vague(Vague::Decimal), other) | (other, TypeKind::Vague(Vague::Decimal)) => { | ||||
|                 match other { | ||||
|                     TypeKind::Vague(Vague::Unknown) => Ok(TypeKind::Vague(Vague::Decimal)), | ||||
|                     TypeKind::Vague(Vague::Decimal) => Ok(TypeKind::Vague(Vague::Decimal)), | ||||
|                     TypeKind::F16 | ||||
|                     | TypeKind::F32B | ||||
|                     | TypeKind::F32 | ||||
|                     | TypeKind::F64 | ||||
|                     | TypeKind::F80 | ||||
|                     | TypeKind::F128 | ||||
|                     | TypeKind::F128PPC => Ok(other.clone()), | ||||
|                     _ => Err(ErrorKind::TypesIncompatible(self.clone(), other.clone())), | ||||
|                 } | ||||
|             } | ||||
|             (TypeKind::Vague(Vague::Unknown), other) | (other, TypeKind::Vague(Vague::Unknown)) => { | ||||
|                 Ok(other.clone()) | ||||
|             } | ||||
|  | ||||
| @ -734,6 +734,13 @@ impl Literal { | ||||
|                 (L::U32(_), TypeKind::U32) => self, | ||||
|                 (L::U64(_), TypeKind::U64) => self, | ||||
|                 (L::U128(_), TypeKind::U128) => self, | ||||
|                 (L::F16(_), TypeKind::F16) => self, | ||||
|                 (L::F32(_), TypeKind::F32) => self, | ||||
|                 (L::F32B(_), TypeKind::F32B) => self, | ||||
|                 (L::F64(_), TypeKind::F64) => self, | ||||
|                 (L::F80(_), TypeKind::F80) => self, | ||||
|                 (L::F128(_), TypeKind::F128) => self, | ||||
|                 (L::F128PPC(_), TypeKind::F128PPC) => self, | ||||
|                 (L::Bool(_), TypeKind::Bool) => self, | ||||
|                 (L::String(_), TypeKind::StringPtr) => self, | ||||
|                 // TODO make sure that v is actually able to fit in the
 | ||||
| @ -748,6 +755,13 @@ impl Literal { | ||||
|                 (L::Vague(VagueL::Number(v)), TypeKind::U32) => L::U32(v as u32), | ||||
|                 (L::Vague(VagueL::Number(v)), TypeKind::U64) => L::U64(v as u64), | ||||
|                 (L::Vague(VagueL::Number(v)), TypeKind::U128) => L::U128(v as u128), | ||||
|                 (L::Vague(VagueL::Decimal(v)), TypeKind::F16) => L::F16(v as f32), | ||||
|                 (L::Vague(VagueL::Decimal(v)), TypeKind::F32) => L::F32(v as f32), | ||||
|                 (L::Vague(VagueL::Decimal(v)), TypeKind::F32B) => L::F32B(v as f32), | ||||
|                 (L::Vague(VagueL::Decimal(v)), TypeKind::F64) => L::F64(v as f64), | ||||
|                 (L::Vague(VagueL::Decimal(v)), TypeKind::F80) => L::F80(v as f64), | ||||
|                 (L::Vague(VagueL::Decimal(v)), TypeKind::F128) => L::F128(v as f64), | ||||
|                 (L::Vague(VagueL::Decimal(v)), TypeKind::F128PPC) => L::F128PPC(v as f64), | ||||
|                 (_, TypeKind::Vague(_)) => self, | ||||
|                 _ => Err(ErrorKind::LiteralIncompatible(self, hint.clone()))?, | ||||
|             }) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user