Skip to content

autofree - variable undeclared - C builder error #20690

@mamoss-oss

Description

@mamoss-oss

Describe the bug

Compiling the example code with autofree option results in a compiler error

Reproduction Steps

module main

fn f(s string) ?[]u8 {
    if s == '' {
        return none
    }
    return [u8(104), 105]
}

fn main() {
    text := if temp := f('') {
        temp.str()
    } else if temp := f('something') {
        temp.str()
    } else {
        return
    }
    println(text)
}
v -autofree .

Expected Behavior

No error

Current Behavior

❯ v -cg -autofree .
/tmp/v_1000/autofree_error.01HNBMATFZWHF0JMW8F2KNQ4SC.tmp.c:12816: error: 'text' undeclared
builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.4 804a7bd

Environment details (OS name and version, etc.)

Arch Linux x86

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AutofreeBugs/feature requests, that are related to -autofree.BugThis tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions