use unused typevar when encountering unknown value or lambda parameter - type inferencing still not entirely correct

This commit is contained in:
Joeri Exelmans 2025-05-17 10:38:54 +02:00
parent d7a4e210a2
commit 496463bbac
8 changed files with 94 additions and 66 deletions

View file

@ -3,7 +3,7 @@ import { useContext, useInsertionEffect } from "react";
import { Editor, type EditorState } from "./Editor";
import { Value } from "./Value";
import { type SetStateFn, type State2Props } from "./Editor";
import { evalCallBlock, evalEditorBlock, scoreResolved } from "./eval";
import { evalCallBlock, evalCallBlock2, evalEditorBlock, scoreResolved } from "./eval";
import { type ResolvedType } from "./eval";
import "./CallBlock.css";
import { EnvContext } from "./EnvContext";
@ -97,6 +97,7 @@ export function CallBlockNoSugar({ state, setState, suggestionPriority }: CallBl
evalEditorBlock(state.fn, env), // fn *may* be set
inputSuggestion[2], // suggestions will be for input
suggestionPriority, // priority function we get from parent block
env,
)}
/>
</div>
@ -105,8 +106,8 @@ export function CallBlockNoSugar({ state, setState, suggestionPriority }: CallBl
</span>;
}
function computePriority(fn: ResolvedType, input: ResolvedType, outPriority: (s: SuggestionType) => number) {
const resolved = evalCallBlock(fn, input);
function computePriority(fn: ResolvedType, input: ResolvedType, outPriority: (s: SuggestionType) => number, env) {
const resolved = evalCallBlock2(fn, input, env);
return scoreResolved(resolved, outPriority);
}
@ -131,6 +132,7 @@ function FunctionHeader({ fn, setFn, input, onFnCancel, suggestionPriority }) {
fnSuggestion[2],
evalEditorBlock(fn.input, env),
suggestionPriority,
env,
)}
/>;
}
@ -153,6 +155,7 @@ function FunctionName({fn, setFn, onFnCancel, suggestionPriority, input}) {
fnSuggestion[2], // suggestions will be for function
evalEditorBlock(input, env), // input *may* be set
suggestionPriority, // priority function we get from parent block
env,
)}
/>
</span>;
@ -180,6 +183,7 @@ function InputParams({ fn, setFn, input, setInput, onInputCancel, depth, errorDe
evalEditorBlock(fn.fn, env),
inputSuggestion[2],
suggestionPriority,
env,
)}
/>;
}
@ -199,6 +203,7 @@ function InputParams({ fn, setFn, input, setInput, onInputCancel, depth, errorDe
evalEditorBlock(fn, env), // fn *may* be set
inputSuggestion[2], // suggestions will be for input
suggestionPriority, // priority function we get from parent block
env,
)}
/>
</div>;