V: segfault when passing table as reference

Created on 30 Nov 2020  路  2Comments  路  Source: vlang/v

V version: This as a base: https://github.com/vlang/v/pull/7043/checks?check_run_id=1473963793
OS: Ubuntu

What did you do?

module main

import v.parser
import v.table
import v.pref
import v.ast

fn main() {
    scope := ast.Scope{
        parent: 0
    }
    pref := pref.Preferences{}
    table := table.new_table()

    code := 'module main

fn main() {
    println(\'Hello World\')
}
'
    parsed_file := parser.parse_text(code, &table, .parse_comments, &pref, &scope)
    println(parsed_file.warnings)
}

What did you expect to see?
Either it works or an V error.

What did you see instead?
segfault

This works

module main

import v.parser
import v.table
import v.pref
import v.ast

fn main() {
    scope := ast.Scope{
        parent: 0
    }
    pref := pref.Preferences{}
    table := table.new_table()

    code := 'module main

fn main() {
    println(\'Hello World\')
}
'
    // changed this line
    parsed_file := parser.parse_text(code, table, .parse_comments, &pref, &scope)
    println(parsed_file.warnings)
}
Bug

Most helpful comment

table.new_table() already outputs &Table
&table would just result to being &&Table

V should return an error for this

All 2 comments

table.new_table() already outputs &Table
&table would just result to being &&Table

V should return an error for this

Great find, very important bug to fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shouji-kazuo picture shouji-kazuo  路  3Comments

clpo13 picture clpo13  路  3Comments

choleraehyq picture choleraehyq  路  3Comments

ArcDrake picture ArcDrake  路  3Comments

lobotony picture lobotony  路  3Comments