local X = @record{y: integer}
function X:A(a: facultative(stringview) <comptime>)
## if a.type.is_niltype then
print'A is niltype'
## else
print(#['a is ' .. a.value]#)
## end
end
Using it without method call syntax sugar works:
local z: X = {0}
X.A(z)
print'---'
X.A(z, 'hello world')
However, using the syntax sugar produces an error:
local z: X = {0}
z:A()
print'---'
z:A('hello world')
error code (gcc):
C compilation for 'nelua_cache/testes' failed:
nelua_cache/testes.c: In function ‘nelua_main’:
nelua_cache/testes.c:90:28: error: incompatible type for argument 2 of ‘testes_X_A__2’
90 | testes_X_A__2(&testes_z, ((nlstringview){(uint8_t*)__strlit4, 11}));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| nlstringview
nelua_cache/testes.c:80:49: note: expected ‘nlniltype’ but argument is of type ‘nlstringview’
80 | void testes_X_A__2(testes_X_ptr self, nlniltype a) {
| ~~~~~~~~~~^
Base code to reproduce:
Using it without method call syntax sugar works:
However, using the syntax sugar produces an error:
error code (gcc):