Skip to content

non-standard error message when incorrectly returning a template string from a function #18309

Closed

Description

@jonathanouwerx

Describe the bug

When incorrectly returning a string (via return $tmpl()) from a function that has a different return type, V gives a compiler error rather than a standard return type error message.

Expected Behavior

I expected to get the following error:
error: cannot use `string` as type `int` in return argument

Current Behavior

I get a builder error with the following message:
/tmp/v_501/main.3698560348010379656.tmp.c:12450:9: error: returning 'string' (aka 'struct string') from a function with incompatible result type 'int'

Reproduction Steps

You also need to add an file in the same directory named template.md. The contents can be anything.

fn main() {
    println(return_item())
}

fn return_item () int {
    return '$tmpl('template.md')'
}

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.3.4 05b832a

Environment details (OS name and version, etc.)

V full version: V 0.3.4 93a2ffa.05b832a
OS: macos, macOS, 13.3.1, 22E772610a
Processor: 8 cpus, 64bit, little endian, Apple M1

CC version: Apple clang version 14.0.3 (clang-1403.0.22.14.1)
thirdparty/tcc status: thirdparty-macos-arm64 a668e5a0

Activity

  1. added
    BugThis tag is applied to issues which reports bugs.
    on May 30, 2023
  2. self-assigned this
    on Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions