Skip to content

Call Overload Not Working as Expected #58

@uuuutsu

Description

@uuuutsu

The following example, as presented in the documentation:

@ OutputStorage {

    => func * {
        'func: func;
        'outputs: [];
    }

    () args... * {
        out: 'function(**args);
        'outputs_: [out];
        * out;
    }

}

...

fails to compile with the error: [SyntaxError] cannot use an identifier after a literal.

However, the behavior varies in different cases:

  • The following example () args * {} transpiles successfully, but the resulting Python script contains multiple sequential function signatures, which leads to a Python SyntaxError:

        def ()(self, sm_args):
            ^
    SyntaxError: invalid syntax
  • Removing the arguments entirely: () * {}, causes the transpiler to crash silently. The error can only be seen when manually compiling from Python:

      File ".../samarium/transpiler.py", line 426, in transpile
        self._process_token(index, token)
      File ".../samarium/transpiler.py", line 993, in _process_token
        func(self, token, push)
      File ".../samarium/transpiler.py", line 638, in _functions
        if self._line[indented + 1] == "=":
           ~~~~~~~~~~^^^^^^^^^^^^^^
    IndexError: list index out of range

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