(proposition: Expression)
| 86 | symbol: string, |
| 87 | cause?: Expression |
| 88 | ): void { |
| 89 | const def = ce.lookupDefinition(symbol); |
| 90 | if (isValueDef(def)) recordAssumedType(ce, def.value, cause); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Infer a promoted type from a value expression. |
| 95 | * This promotes specific types to more general ones suitable for symbols: |
| 96 | * - finite_integer -> integer |
| 97 | * - rational -> real |
| 98 | * - finite_real_number -> real |
| 99 | * - complex/imaginary -> number |
| 100 | */ |
| 101 | function inferTypeFromValue(ce: ComputeEngine, value: Expression): BoxedType { |
| 102 | // finite_integer, integer, etc. -> integer |
| 103 | if (value.type.matches('integer')) return ce.type('integer'); |
| 104 | |
| 105 | // rational -> real |
| 106 | if (value.type.matches('rational')) return ce.type('real'); |
| 107 | |
| 108 | // finite_real_number, real -> real |
| 109 | if (value.type.matches('real')) return ce.type('real'); |
| 110 |
no test coverage detected