vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.54k stars 2.14k forks source link

Compiler crashed on a simple linked list #12892

Open xiaopong opened 2 years ago

xiaopong commented 2 years ago

The command v outdated shows that all modules are up to date, and the V compiler has been just fetched latest from the master branch.

I'm just trying to play around with V by implementing some basic data structures. This code used to compile and work before, but the last couple of weeks, the master branch always crashes on this one.

V doctor:

OS: linux, Debian GNU/Linux 10 (buster)
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
CC version: cc (Debian 8.3.0-6) 8.3.0

getwd: /home/xp/ws-v/v-data-structures
vmodules: /home/xp/.vmodules
vroot: /home/xp/ws-v/v
vexe: /home/xp/ws-v/v/v
vexe mtime: 2021-12-18 16:33:52
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 2ab861e

Git version: git version 2.20.1
Git vroot status: weekly.2021.46-328-g2ab861ef
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 333c14de

What did you do? v -g -o vdbg cmd/v && vdbg main.v

import util.list as l

fn main() {
    mut ll := l.LinkedList<int>{}

    ll.add(1)
    ll.add(2)
    ll.add(3)
    println(ll)

    print_len(ll)
}

fn print_len(list l.List<T>) {
    println("print_len: ")
    println(list.length())
}

What did you expect to see?

It should compile

What did you see instead?

================ V panic ================
   module: v.ast
 function: default_table_panic_handler()
  message: get_type_symbol: invalid type (typ=0 idx=0). Compiler bug. This should never happen. Please report the bug using `v bug file.v`.

     file: /home/xp/ws-v/v/vlib/v/ast/table.v:70
   v hash: 2ab861e
=========================================
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/builtin/builtin.c.v:53: at panic_debug: Backtrace
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/ast/table.v:70: by v__ast__default_table_panic_handler
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/ast/table.v:76: by v__ast__Table_panic
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/ast/table.v:642: by v__ast__Table_get_type_symbol
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/interface.v:193: by v__checker__Checker_resolve_generic_interface
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:1700: by v__checker__Checker_type_implements
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/fn.v:738: by v__checker__Checker_fn_call
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:1624: by v__checker__Checker_call_expr
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:3192: by v__checker__Checker_expr
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:2451: by v__checker__Checker_stmt
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:3085: by v__checker__Checker_stmts_ending_with_expression
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:3063: by v__checker__Checker_stmts
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/fn.v:296: by v__checker__Checker_fn_decl
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:2484: by v__checker__Checker_stmt
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:207: by v__checker__Checker_check
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/checker/checker.v:264: by v__checker__Checker_check_files
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/builder/builder.v:103: by v__builder__Builder_middle_stages
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/builder/builder.v:127: by v__builder__Builder_front_and_middle_stages
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/builder/cbuilder/cbuilder.v:38: by v__builder__cbuilder__gen_c
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/builder/cbuilder/cbuilder.v:54: by v__builder__cbuilder__build_c
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/builder/cbuilder/cbuilder.v:33: by v__builder__cbuilder__compile_c
/tmp/v_1000/../../../../../../home/xp/ws-v/v/vlib/v/builder/compile.v:34: by v__builder__compile
/tmp/v_1000/../../../../../../home/xp/ws-v/v/cmd/v/v.v:144: by main__main
/tmp/v_1000/../../../../../../tmp/v_1000/vdbg.6785613601244780812.tmp.c:17694: by main
Le0Developer commented 2 years ago

You didn't include your linked list implementation.

felipensp commented 3 days ago

Can you try again with a newer V version?