acton icon indicating copy to clipboard operation
acton copied to clipboard

Compilation error for await actor call - CodeGen outputting invalid C

Open plajjan opened this issue 2 years ago • 4 comments

Acton Version

0.16.0.20230830.21.52.57

Steps to Reproduce

This is the smallest reproduction I can find right now:

class LogMessage:
    def __init__(self):
        pass

actor Handler():
    def handle(m: LogMessage):
        pass

class Logger:
    def __init__(self):
        self.handler = Handler()

    def log(self):
        self.handler.handle(LogMessage())

I'm really trying to build a logging module, which also reproduces the problem:

  • git pull
  • git checkout logging
  • make
  • dist/bin/actonc test/stdlib_auto/test_logging.act

Expected Behavior

Successful compilation!

Actual Behavior

Compilation error

zig build-lib Acton Debug x86_64-linux-gnu.2.27: error: error(compilation): clang failed with stderr: /home/kll/terastream/acton/base/out/types/logging.c:165:108: error: too few arguments to function call, expected 2, have 1
/home/kll/terastream/acton/base/rts/rts.h:183:4: note: '$AWAIT' declared here

plajjan avatar Sep 09 '23 09:09 plajjan

@nordlander this one has got me real stumped. I don't see how this code is any different than most other code we write where we have plenty of actor calls left and right. How can this become a problem here?

plajjan avatar Sep 09 '23 09:09 plajjan

This is the smallest reproduction I can find right now:

class LogMessage:
    def __init__(self):
        pass

actor Handler():
    def handle(m: LogMessage):
        pass

class Logger:
    def __init__(self):
        self.handler = Handler()

    def log(self):
        self.handler.handle(LogMessage())

I still don't get why we haven't seen this before. We never had this code pattern before?

I also did try, on a whim, to back out the recent exception handling but it's the same error.

plajjan avatar Sep 09 '23 14:09 plajjan

Calling the actor method in the classes init method works

class LogMessage:
    def __init__(self):
        pass

actor Handler():
    def handle(m: LogMessage):
        pass

class Logger:
    def __init__(self):
        self.handler = Handler()
        self.handler.handle(LogMessage())

#    def log(self):
#        self.handler.handle(LogMessage())

I looked at the resulting C code. It infers an async call (i.e. not AWAIT) whereas the original reproduction case results in an AWAIT.

If I force async, it works:

class LogMessage:
    def __init__(self):
        pass

actor Handler():
    def handle(m: LogMessage):
        pass

class Logger:
    def __init__(self):
        self.handler = Handler()

    def log(self):
        async self.handler.handle(LogMessage())
Building project in /home/kll/terastream/acton/base
  Compiling bjanka.act for release
   Already up to date, in    0.000 s
  Final compilation step
   Finished final compilation step in   0.010 s

plajjan avatar Sep 09 '23 14:09 plajjan

Discussed during #1484. This one's a little tricky to solve. Since there is a workaround, it's not top priority. @nordlander should get around to it at a later time.

plajjan avatar Sep 13 '23 13:09 plajjan