The analyser currently defaults to StaticType::Any in several places that would require a proper
Hindley-Milner (or similar) type inference system to resolve correctly. These are all tightly
coupled and should be addressed together.
Affected areas
-
Function parameter types (ndc_analyser/src/analyser.rs)
All function parameters default to StaticType::Any. A proper inference pass is needed to
propagate types from call-sites back to parameter positions.
-
None / Option type inference (ndc_analyser/src/analyser.rs)
None is typed as Option<Any>. HM inference (or mandatory type annotations on the binding
site) is needed to determine the inner type.
-
Empty list type (ndc_analyser/src/analyser.rs)
[] is typed as List<Any>. Needs type parameters on List plus inference from usage context.
-
Empty / partially-typed map (ndc_analyser/src/analyser.rs)
Map key/value types default to Any when no elements are present. Same issue as empty list.
-
For-loop iteration element type (ndc_analyser/src/analyser.rs)
The element type of a sequence in a for loop falls back to Any. Needs type parameters on
sequence types (List, Range, etc.) to propagate the element type.
-
Binding::Dynamic return type (ndc_analyser/src/analyser.rs)
When a call resolves to Binding::Dynamic, the analyser returns a Function { return: Any }
placeholder. With better inference the actual return type could be narrowed.
The analyser currently defaults to
StaticType::Anyin several places that would require a properHindley-Milner (or similar) type inference system to resolve correctly. These are all tightly
coupled and should be addressed together.
Affected areas
Function parameter types (
ndc_analyser/src/analyser.rs)All function parameters default to
StaticType::Any. A proper inference pass is needed topropagate types from call-sites back to parameter positions.
None/ Option type inference (ndc_analyser/src/analyser.rs)Noneis typed asOption<Any>. HM inference (or mandatory type annotations on the bindingsite) is needed to determine the inner type.
Empty list type (
ndc_analyser/src/analyser.rs)[]is typed asList<Any>. Needs type parameters onListplus inference from usage context.Empty / partially-typed map (
ndc_analyser/src/analyser.rs)Map key/value types default to
Anywhen no elements are present. Same issue as empty list.For-loop iteration element type (
ndc_analyser/src/analyser.rs)The element type of a sequence in a
forloop falls back toAny. Needs type parameters onsequence types (
List,Range, etc.) to propagate the element type.Binding::Dynamicreturn type (ndc_analyser/src/analyser.rs)When a call resolves to
Binding::Dynamic, the analyser returns aFunction { return: Any }placeholder. With better inference the actual return type could be narrowed.