Skip to content

TOML encoding C compilation error #24435

@stilvoid

Description

@stilvoid
V version: V 0.4.10, press to see full `v doctor` output
V full version V 0.4.10 9b1937a.
OS macos, macOS, 15.4.1, 24E263
Processor 8 cpus, 64bit, little endian, Apple M1 Pro
Memory 0.24GB/16GB
V executable /opt/homebrew/Cellar/vlang/0.4.10/libexec/v
V last modified time 2025-03-20 11:42:00
V home dir OK, value: /opt/homebrew/Cellar/vlang/0.4.10/libexec
VMODULES OK, value: /Users/steve/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/steve/code/github.com/stilvoid/bleng
Git version git version 2.39.5 (Apple Git-154)
V git status 4.5.1 (64816 commit(s) behind V master)
.git/config present false
cc version Apple clang version 17.0.0 (clang-1700.0.13.3)
gcc version Apple clang version 17.0.0 (clang-1700.0.13.3)
clang version Apple clang version 17.0.0 (clang-1700.0.13.3)
tcc version N/A
tcc git status N/A
emcc version N/A
glibc version N/A

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

module main

import toml

fn main() {
    // Create a TOML document
    mut doc := map[string]toml.Any{}
    doc['key'] = toml.Any('value')
    
    // Try to encode it - this is where the bug occurs
    toml_content := toml.encode(doc)
    
    println(toml_content)
}

What did you see?

================== C compilation error (from cc): ==============
cc: /tmp/v_501/toml_bug.01JTRA3CD8YK3RM5YZNS5PM84Q.tmp.c:12313:12: error: unexpected type name 'map': expected expression
cc:  12313 |                                 return map[string]toml__Any_to_toml(typ);
cc:        |                                        ^
cc: /tmp/v_501/toml_bug.01JTRA3CD8YK3RM5YZNS5PM84Q.tmp.c:12313:16: error: unexpected type name 'string': expected expression
cc:  12313 |                                 return map[string]toml__Any_to_toml(typ);
cc:        |                                            ^
cc: /tmp/v_501/toml_bug.01JTRA3CD8YK3RM5YZNS5PM84Q.tmp.c:12313:23: error: expected ';' after return statement
cc:  12313 |                                 return map[string]toml__Any_to_toml(typ);
cc:        |                                                   ^
cc:        |                                                   ;
cc: 3 errors generated.
================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

What did you expect to see?

Correctly encoded toml or a V error, not a C compilation error.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions