← 输入框|github.com|刷新
Skip to content

Internal Compiler Error: Unhandled exception #2312

Closed

Description

@davidbrochart

It seems asyncio is not supported yet? I get the following error while importing it:

semantic error: Could not find the module 'asyncio'. If an import path is available, please use the `-I` option to specify it

As a workaround, I wanted to try this simple coroutine runner:

async def main():
    print("done")

def run_async_fn(async_fn, *args, **kwargs):
    coro = async_fn(*args, **kwargs)
    try:
        coro.send(None)
    except StopIteration as exc:
        return exc.value
    else:
        raise RuntimeError("Cannot run async function")

run_async_fn(main)

But I get:

Internal Compiler Error: Unhandled exception

Activity

  1. certik commented on Sep 4, 2023

    @certik
    Contributor

    Yes, we don't support asyncio natively yet. The second example should give a nice error, so that's a bug. Thanks for reporting it!

  2. davidbrochart commented on Sep 5, 2023

    @davidbrochart
    Author

    Actually I get a better error message with lpython from conda-forge (the above was with lpython compiled locally):

    Internal Compiler Error: Unhandled exception
    Traceback (most recent call last):
    LCompilersException: visit_AsyncFunctionDef() not implemented
    

    So I guess this issue should be closed?

  3. certik commented on Sep 5, 2023

    @certik
    Contributor

    Leave it open. This error message is a general developer error message that we have not implemented visit_AsyncFunctionDef in the AST->ASR visitor.

    However the error message should actually be the user error message where we underline the code that is not supported and explain why, possibly linking to a github issue.

  4. added
    good first issue
    on Sep 27, 2023
  5. ujjwaltwitx commented on Nov 30, 2023

    @ujjwaltwitx
    Contributor

    Hello everyone, I want to work on this issue but I have no idea on how to approach this. Can someone just guide me a bit in the right direction.

  6. certik commented on Nov 30, 2023

    @certik
    Contributor

    @ujjwaltwitx you have to override the function visit_AsyncFunctionDef in AST to ASR, and raise a nice error message to the user. You can watch https://www.youtube.com/watch?v=yuYsyM08bss to get an idea how the internals work.

  7. ujjwaltwitx commented on Dec 1, 2023

    @ujjwaltwitx
    Contributor

    Sorry for replying this late. I was busy doing some other work. I will watch the video and if I face any difficulties, I will definitely get back to the community for help.

  8. ujjwaltwitx commented on Dec 11, 2023

    @ujjwaltwitx
    Contributor

    I have implemented visit_AsyncFunctionDef in SymbolTableVisitor class. Here's the definition of the function

    void visit_AsyncFunctionDef(const AST::AsyncFunctionDef_t &x){
            try
            {
                // to be implemented
            }
            catch(const std::exception& e)
            {
                std::cerr << e.what() << '\n';
            }        
        }
    

    Am I required to add something more to this function. I have also add the visit_AsyncFunctionDef in BodyVisitor class. Here's the definition of the same

    void visit_AsyncFunctionDef(const AST::AsyncFunctionDef_t &x) {
            try
            {
                // BodyVisitor for visit_AsyncFunctionDef to be implemented
            }
            catch(const std::exception& e)
            {
                std::cerr << e.what() << '\n';
            }
        }
    

    Any feedback will be much appreciated.

  9. syheliel commented on Feb 16, 2024

    @syheliel
    Contributor

    This problem has been fixed in #2442 . should we close this issue?

  10. certik commented on Feb 16, 2024

    @certik
    Contributor

    Here is what I get on the above code now:

    $ lpython a.py 
    semantic error: The `async` keyword is currently not supported
     --> a.py:1:1 - 2:17
      |
    1 |    async def main():
      |    ^^^^^^^^^^^^^^^^^...
    ...
      |
    2 |        print("done")
      | ...^^^^^^^^^^^^^^^^^ 
    
    
    Note: Please report unclear or confusing messages as bugs at
    https://github.com/lcompilers/lpython/issues.

    So I think this issue is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions