handle empty __init__ correctly #32

Closed
opened 2021-09-28 17:03:39 +08:00 by pca006132 · 1 comment
Contributor

This should be a host object:

@kernel
class X:
  pass

This should be a device object:

@kernel 
class X:
  @kernel
  def __init__(self):
    pass
This should be a host object: ```python @kernel class X: pass ``` This should be a device object: ```python @kernel class X: @kernel def __init__(self): pass ```
Owner

Related: if __init__ exists and is not decorated with @kernel or @portable, attempting to create the object on the device should fail with a clear error message.

Currently this can either succeed (with the compiler using a default empty __init__) or, if __init__ takes arguments that are correctly passed by the caller, fail with this confusing error:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "Too many arguments. at line 10 column 21"', nac3artiq/src/lib.rs:296:44
Related: if ``__init__`` exists and is not decorated with ``@kernel`` or ``@portable``, attempting to create the object on the device should fail with a clear error message. Currently this can either succeed (with the compiler using a default empty ``__init__``) or, if ``__init__`` takes arguments that are correctly passed by the caller, fail with this confusing error: ``` thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "Too many arguments. at line 10 column 21"', nac3artiq/src/lib.rs:296:44 ```
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#32
No description provided.