[stdlib] Command Subprocess cannot find suitable function 'or'
Caddox opened this issue · 0 comments
With the file example.vale:
import stdlib.*;
import stdlib.command.*;
import stdlib.stringutils.*;
import stdlib.path.*;
import stdlib.optutils.*;
exported func main() {
prog = "valec";
args = List<StrSlice>()
.add("build".slice())
.add("mymod=src".slice())
.add("--output_dir".slice())
.add("target".slice());
relative_path = Path("~/")&.resolve().str();
Subprocess(prog, &args, Some(relative_path)).expect("Failed to find " + prog + " in path");
}
Attempting to build with valec produces the following (failed) output:
$ valec build --verbose true mymod=example.vale --output_dir target
Parsing command line inputs
Invoking Frontend
Moving existing output directory target to /tmp/old_output_dir_6984894478946.
Running:
/usr/bin/java -cp /home/caddox/projects/Vale/Frontend.jar dev.vale.passmanager.PassManager build --output_dir target --sanity_check true --verbose stdlib=/home/caddox/projects/Vale/stdlib/src mymod=/home/caddox/projects/testing/src/example.vale
Error: stdlib.command:/home/caddox/projects/Vale/stdlib/src/command/command.vale:65:50 error T
handle = launch_command(cmd_array, maybe_cwd.or(""));
Couldn't find a suitable function or(&Opt<str>, str). Rejected candidates:
stdlib.optutils:/home/caddox/projects/Vale/stdlib/src/optutils/optutils.vale:45:1:
Expected an instantiation of Opt but got &Opt<str>
func or<F, T>(self Opt<T>, func F) T
^ T: (unknown)
^^^^^^ _2111: &Opt<str>
^^^ _211211: Opt
where func(&F)_ {
^ _11141: (unknown)
^^^^^^^^^ _1111: (unknown)
^^^^^^^^^ _1115: (unknown)
^^^^^^^^^ _1113: (str)
if self.isEmpty() {
Steps:
Supplied:
(arg 0): &Opt<str>
(arg 1): str
(arg 1) -> F
F: str
_11121 = &F
_11121: str
_1113 = (_11121)
_1113: (str)
(arg 0) -> _2111
_2111: &Opt<str>
_211211 = Opt
_211211: Opt
Unsolved rule: _1111 = "__call"
Unsolved rule: _1115 = Prot[_1111, _1113, _11141]
Unsolved rule: _2111 = _211211<T>
stdlib.optutils:/home/caddox/projects/Vale/stdlib/src/optutils/optutils.vale:55:1:
func or<F, T>(self &Opt<T>, func F) &T
Couldn't find function to call: Couldn't find a suitable function __call(str). Rejected candidates:
stdlib.math:/home/caddox/projects/Vale/stdlib/src/math/math.vale:42:1:
func __call(this &IntEquator, a int, b int) bool { a == b }
Number of params doesn't match! Supplied 1 but function takes 3
stdlib.math:/home/caddox/projects/Vale/stdlib/src/math/math.vale:39:1:
func __call(this &IntHasher, x int) int { x }
Number of params doesn't match! Supplied 1 but function takes 2
stdlib:/home/caddox/projects/Vale/stdlib/src/ifunction1.vale:4:1:
Expected an instantiation of IFunction1.anonymous but got str
func __call(virtual self &IFunction1<M, P1, R>, p1 P1) R;
^ R: (unknown)
^^ P1: (unknown)
^ M: (unknown)
^^^^^^^^^^ _2112211: (unknown)
^^^^^^^^^^^^^^^^^^^^ _21121: (unknown)
^^^^^^^^^^^^^^^^^^^^^ _2111: (unknown)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (self ownership): share
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (anon sub parent interface): (unknown)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (self kind): str
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (self kind template): IFunction1.anonymous
^ (anon member 0): (unknown)
}
Steps:
Supplied:
(arg 0): str
(arg 0) -> (self)
(self): str
(self) = Ref((self ownership), (self kind))
(self ownership): share
(self kind): str
(self kind template) = (anon substruct template of IFunction1)
(self kind template): IFunction1.anonymous
Unsolved rule: _2112211 = IFunction1
Unsolved rule: inherit M
Unsolved rule: inherit P1
Unsolved rule: inherit R
Unsolved rule: _21121 = _2112211<M, P1, R>
Unsolved rule: _2111 = &_21121
Unsolved rule: _2111 = Ref((self ownership), (anon sub parent interface))
Unsolved rule: (self kind) = (self kind template)<M, P1, R, (anon member 0)>
stdlib.stringutils:/home/caddox/projects/Vale/stdlib/src/stringutils/stringutils.vale:282:1:
func __call(self &StrSliceEquator, a StrSlice, b StrSlice) bool {
Number of params doesn't match! Supplied 1 but function takes 3
stdlib.stringutils:/home/caddox/projects/Vale/stdlib/src/stringutils/stringutils.vale:287:1:
func __call(self &StrHasher, original_str str) int {
Number of params doesn't match! Supplied 1 but function takes 2
stdlib.stringutils:/home/caddox/projects/Vale/stdlib/src/stringutils/stringutils.vale:272:1:
func __call(self &StrSliceHasher, s StrSlice) int {
Number of params doesn't match! Supplied 1 but function takes 2
stdlib.stringutils:/home/caddox/projects/Vale/stdlib/src/stringutils/stringutils.vale:298:1:
func __call(self &StrEquator, a str, b str) bool {
Number of params doesn't match! Supplied 1 but function takes 3
:functor1.vale:-1:
:functor1.vale
Expected an instantiation of Functor1 but got str
Steps:
Supplied:
(arg 0): str
(arg 0) -> _2111
_2111: str
_2111 = &_21121
_21121: str
_2112211 = Functor1
_2112211: Functor1
Unsolved rule: _113222 = (Param1Type)
Unsolved rule: _1131 = Prot[_1132111, _113222, RetType]
Unsolved rule: F = _1131
Unsolved rule: _21121 = _2112211<M, F>
where func(&F)_ {
^ _11141: (unknown)
^^^^^^^^^ _1115: (unknown)
^^^^^^^^^ _1111: "__call"
^^^^^^^^^ _1113: (str)
if self.isEmpty() {
Steps:
Supplied:
(arg 0): &Opt<str>
(arg 1): str
(arg 1) -> F
F: str
_11121 = &F
_11121: str
_1113 = (_11121)
_1113: (str)
(arg 0) -> _2111
_2111: &Opt<str>
_2111 = &_21121
_21121: Opt<str>
_2112211 = Opt
_2112211: Opt
_21121 = _2112211<T>
T: str
_311 = &T
_311: str
_1111 = "__call"
_1111: "__call"
Unsolved rule: _1115 = Prot[_1111, _1113, _11141]
stdlib:/home/caddox/projects/Vale/stdlib/src/logic.vale:7:1:
func or(a bool, b bool) bool { a or b }
Index 0 argument &Opt<str> can't be given to expected parameter bool
Frontend returned error code 22, aborting.
(panic)
Long story short: maybe_cwd.or("")
in stdlib.command
is very unhappy.
Vale/stdlib/src/command/command.vale
Line 65 in 8b73ca1
Interestingly, it looks like this exact issue was fixed in a file that's not in the stdlib (Vale/Utils/src/command2/command.vale
) but I would rather not bring an internal compiler dependency into my program if I don't have to.
Fixed here:
Vale/Utils/src/command2/command.vale
Lines 103 to 110 in 8b73ca1
Environment Details
Distro: Ubuntu on wsl2
Compiler release: Vale-Ubuntu-0.2.0.15.zip (also fails on Vale-Ubuntu-0.2.0.11.zip, but for different reasons)
Java: openjdk 11.0.15 2022-04-19
clang: 10.0.0-4ubuntu1
Otherwise, I've been having fun with the language. If it's not too much issue, would there be a problem replacing/merging Utils/command2
and stdlib/command
together?