-
-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Description
If I have a file called test.roc:
app [main!] {
pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst"
}
ValueCombinationMethod := [
Modulo,
]
Value := [
UInt(U64),
CombinedValue({
combination_method: ValueCombinationMethod,
value1: Value,
value2: Value,
}),
]
TokenContents : []
TokenizerResult : (
Try(TokenContents, Str),
U64, # Index of start of token/error
U64, # New index in file
)
get_next_token : List(U8), U64 -> TokenizerResult
get_next_token = |file, index| {
(Err("todo"), 0, 0)
}
parse_value : List(U8), TokenizerResult, List(Str) -> Try((Value, U64), Str)
parse_value = |file, result, possibilities| {
(first_value, var $index) = parse_first_value(file, result, possibilities)?
(token, token_pos, $index) = get_next_token(file, $index)
(value1, token2, token2_pos) = match (first_value, token) {
(VariableReference(name), Ok(OpenBracketToken)) => {
# TODO
(t2, t2_pos, $index) = get_next_token(file, $index)
(FunctionCall({name, args: []}), t2, t2_pos)
}
_ => (first_value, token, token_pos)
}
combination_method1 : ValueCombinationMethod
combination_method1 = Modulo
(value2, $index) = parse_value(file, get_next_token(file, $index), [])
value : Value
value = match value2 {
CombinedValue({combination_method: combination_method2, value1: value2A, value2: value2B}) => {
# Combination method 1 is ran first
CombinedValue({
combination_method: combination_method2,
value1: CombinedValue({
combination_method: combination_method1,
value1: value1,
value2: value2A,
}),
value2: value2B,
})
}
_ => CombinedValue({combination_method: combination_method1, value1, value2})
}
Ok((value, $index))
}
main! : List(Str) => Try({}, [Exit(I32)])
main! = |_args| {
(value, _index) = parse_value(Str.to_utf8("15 + 4 == 19"), 0, []).map_err!(|e| {
Stderr.line!(e)
Exit(1)
})?
Stdout.line!(Str.inspect(value))
Ok({})
}
Then, when I try to run the code with roc ./test.roc, I get the error:
thread 405138 panic: trying to add var at rank 2, but current rank is 1
/home/jg/roc/src/types/generalize.zig:473:32: 0x4b8daff in addVarToRank (mod.zig)
std.debug.panic("trying to add var at rank {}, but current rank is {}", .{ @intFromEnum(rank), @intFromEnum(self.current_rank) });
^
/home/jg/roc/src/types/generalize.zig:161:47: 0x4ba9d16 in generalize (mod.zig)
try self.tmp_var_pool.addVarToRank(resolved.var_, resolved.desc.rank);
^
/home/jg/roc/src/check/Check.zig:1552:40: 0x4b90d35 in checkDef (mod.zig)
try self.generalizer.generalize(self.gpa, &env.var_pool, env.rank(), should_generalize);
^
/home/jg/roc/src/check/Check.zig:1053:26: 0x4919b2b in checkFile (mod.zig)
try self.checkDef(def_idx, &env);
^
/home/jg/roc/src/cli/main.zig:2150:30: 0x4536ec9 in setupSharedMemoryWithModuleEnv (main.zig)
try app_checker.checkFile();
^
/home/jg/roc/src/cli/main.zig:1169:58: 0x4546aaa in rocRun (main.zig)
const shm_result = try setupSharedMemoryWithModuleEnv(ctx, args.path, args.allow_errors);
^
/home/jg/roc/src/cli/main.zig:695:19: 0x48542c7 in mainArgs (main.zig)
rocRun(&ctx, run_args) catch |err| switch (err) {
^
/home/jg/roc/src/cli/main.zig:601:13: 0x48563b8 in main (main.zig)
mainArgs(&allocs, args) catch {
^
/home/jg/binary-repository/downloadedSources/zig/lib/std/start.zig:627:37: 0x4856971 in main (std.zig)
const result = root.main() catch |err| {
^
/home/jg/binary-repository/downloadedSources/zig/lib/libc/musl/src/env/__libc_start_main.c:95:7: 0x9613419 in libc_start_main_stage2 (/home/jg/binary-repository/downloadedSources/zig/lib/libc/musl/src/env/__libc_start_main.c)
exit(main(argc, argv, envp));
^
???:?:?: 0x95eeb89 in ??? (???)
Unwind error at address `exe:0x95eeb89` (error.MissingFDE), trace may be incomplete
Aborted (core dumped) ../roc/zig-out/bin/roc test3.roc
The version of the compiler that I am using is compiled from 0e0cb64.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels