Skip to content

Error when returning values within macro trailing bodies and block expressions #1889

@vssukharev

Description

Compiler throws an error when compiling such code:

// --- test.c3
fault SomeF
{
  A, B, C
}

macro usz! @insertBody(;@body())
{
  return {| @body(); |};
}

fn void main()
{
  usz! res1 = @insertBody() { return SomeF.A?; };
}

Here is an error:

$ c3c compile-run test.c3
11: 
12: fn void main()
13: {
14:   usz! res1 = @insertBody() { return SomeF.A?; };
                                         ^^^^^^^^
(/home/starleks/coding/probe/c3-sandbox/main.c3:14:38) Error: It is not possible to cast
 from 'void!' to 'void'.

Metadata

Assignees

No one assigned

    Labels

    Discussion neededThis feature needs discussion to iron out details

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions