Skip to content

Invalid InsertValueInst when awaiting multiple coroutines in one expression #844

Description

@salvatore-abello

Description

Codon aborts while compiling an async program that awaits two coroutines in the same print expression.

Reproduction

import asyncio

async def a():
    print("b")

async def b():
    print("c")

async def main():
    p1 = a()
    p2 = b()

    print(await p1, await p2)

asyncio.run(main())

Run:

codon run test.py

Actual behavior

Invalid InsertValueInst operands!
  %31 = insertvalue { {}, {} } undef, ptr %.reload28, 0, !dbg !24057
Invalid InsertValueInst operands!
  %29 = insertvalue { {}, {} } undef, ptr %.reload28, 0, !dbg !24070
Invalid InsertValueInst operands!
  %29 = insertvalue { {}, {} } undef, ptr %.reload28, 0, !dbg !24083
Assert failed: Generated LLVM IR is invalid and has been dumped to '_dump.ll'. Please submit a bug report at https://github.com/exaloop/codon including the code and generated LLVM IR.
Expression: !broken
Source:     /github/workspace/codon/cir/llvm/optimize.cpp:1070

The process aborts with an IOT instruction (core dumped) error.

Expected behavior

The program should run successfully and print:

b
c
None None

Environment

  • Codon: 0.19.6
  • OS: Fedora Linux 43 (Workstation Edition)
  • Kernel: Linux 7.0.9-105.fc43.x86_64
  • Architecture: x86_64
  • CPU: Intel Core Ultra 7 155H

dump.ll.tar.gz

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