Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua's grammar vs Teal's cast #740

Open
fperrad opened this issue Mar 18, 2024 · 2 comments
Open

Lua's grammar vs Teal's cast #740

fperrad opened this issue Mar 18, 2024 · 2 comments
Labels
semantics Unexpected or unsound behaviors

Comments

@fperrad
Copy link
Contributor

fperrad commented Mar 18, 2024

This Lua code fails, but it is not an issue because the extra parentheses are useless

(io.stdout):write('one\n')
(io.stdout):write('two\n')  -- attempt to call a FILE* value
io.stdout:write('one\n')
io.stdout:write('two\n')  -- OK

Now, with Teal, this kind of parentheses is used by cast (and could become widely used)

local record Obj
   meth1: function(self: Obj)
end

local t = {}
do
   (t as Obj):meth1()
   (t as Obj):meth1()  -- not a function: nil
end

The generated Lua looks like:

local t = {}
do
   (t):meth1()(
   t):meth1()
end
@fperrad
Copy link
Contributor Author

fperrad commented Mar 18, 2024

The answer is the few used ;

@hishamhm hishamhm added the semantics Unexpected or unsound behaviors label Mar 19, 2024
@hishamhm
Copy link
Member

Not sure what we can do about this. It's a known gotcha for Lua...

Filed this one under the "semantics" label because it's the one we use for "surprising behaviors", but it really should be under "syntax" :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semantics Unexpected or unsound behaviors
Projects
None yet
Development

No branches or pull requests

2 participants