Type error in workflow mode if function definition at end of input
Let us have this input:
t = ((s: 1, 2, 3))
print(d)
d = f(t.s)
f(x) = x
$ texts script -m workflow -f test.vm
Type error: None:4:8 --> x <--
Invalid type in expression
used here: None:3:5 --> f(t.s) <--
$ texts script -f test.vm
program output: >>>
(s: 1, 2, 3)
<<<
After reordering the statements, i.e. f(x)
before the call, it works in workflow mode:
t = ((s: 1, 2, 3))
print(d)
f(x) = x
d = f(t.s)
Seemingly the error occurs only when the function definition is last in input. Because these code versions work:
t = ((s: 1, 2, 3))
print(d)
d = f(t.s)
f(x) = x
a = 1
t = ((s: 1, 2, 3))
d = f(t.s)
f(x) = x
print(d)
One more related test (with session):
Input > t = ((s: 1, 2, 3)); d = map((x: x**3), t.s)
Input > %hist
WAITING 2024-07-22T11:53:45+02:00 t = ((s: 1, 2, 3))
WAITING 2024-07-22T11:53:45+02:00 d = map((x: x**3), t.s)
Input > f(x) = x; c = f(t.s)
Type error: None:3:8 --> x <--
Invalid type in expression
used here: None:4:6 --> f(t.s) <--
It works again when the definition f(x) = x
is in a separate input.
Input > f(x) = x
Input > %hist
WAITING 2024-07-22T11:53:28+02:00 f(x) = x
WAITING 2024-07-22T11:53:45+02:00 t = ((s: 1, 2, 3))
WAITING 2024-07-22T11:53:45+02:00 d = map((x: x**3), t.s)
Input > c = f(t.s)
Input > %hist
WAITING 2024-07-22T11:53:28+02:00 f(x) = x
WAITING 2024-07-22T11:53:45+02:00 t = ((s: 1, 2, 3))
WAITING 2024-07-22T11:53:45+02:00 d = map((x: x**3), t.s)
WAITING 2024-07-22T11:56:42+02:00 c = f(t.s)
Edited by Ivan Kondov