Samarium icon indicating copy to clipboard operation
Samarium copied to clipboard

Call Overload Not Working as Expected

Open uuuutsu opened this issue 1 year ago • 1 comments

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
    

uuuutsu avatar Sep 19 '24 00:09 uuuutsu

I really want to use the language.. When will the fix be available?

uuuutsu avatar Jan 30 '25 14:01 uuuutsu