Luau Recap: March 2021

Finally! All the code I’ve written using table.insert(t, v) is no longer inferior!

4 Likes

Does this mean we have to rescript our games or does the Customized Lua still work?

2 Likes

I feel like these recaps need something like:

THIS DOES NOT BREAK EXISTING CODE
Luau type annotations are purely optional

Right at the top of the post to stop people panicking that their game will suddenly need re-scripting.

6 Likes

Awesome sauce! Can’t wait to see more coming to this language!

It looks like there was a major regression with inferred types/generic functions, cause now I’m getting lots of warnings where an exported type (Finalizer.Finalizer) is failing type relation with… itself.



For reference, Finalizer.new literally returns an object of the exported type Finalizer.Finalizer

I’ve created a repro:
GenericsRegression.rbxl (23.7 KB)

Removing “AddTask” from my exported type seems to fix this issue, so I’m guessing there’s a problem with relating a generic function to itself.

EDIT: here’s a simplified repro demonstrating the same issue:

--!strict
type MyFunc = <T>(T) -> T

local function returnsMyFunc(): MyFunc
	return function<T>(t: T)
		return t
	end
end

local f: MyFunc = returnsMyFunc()

@zeuxcg

Ah yes, this is a restriction of the current implementation: function types can’t return generic functions or take them as arguments. The error message isn’t much use here :frowning: sorry.

I haven’t tried it, but shouldn’t it be just this?

type MyFunc<T> = (T) -> T

In general I just avoid adding type information to complex code, luau hasn’t come far enough to use in large projects for things like OOP or complex patterns…

Please use any as a temporary workaround; we’re going to investigate this and come back after the break.

We had to revert the change to generic functions anyhow. I think this should solve your issue - please confirm if you get a chance.

2 Likes

Will there be inherent syntax for classes? Writing bunch of metatables can get tedious. Also introduces implicit features, but I don’t think that is possible to change.

global keywords like keyof, implements, extends, interfaces, are those going to be implemented?

On the topic of globals, what about declaring global types.

1 Like

Will there be inherent syntax for classes?

Yes, it’s in our long-term roadmap - eventually it will be there. No details as of yet.

We discourage the use of globals; it’s not very likely that we’ll introduce first-class support for global types, although there’s a tangentially related feature that might see the light of day at some point.

4 Likes

Generics using the old syntax seem to be working now, thanks! Sorry about my tone earlier, just a little annoyed that it seemed like this bug wasn’t going to be addressed because it wasn’t considered to be a supported feature yet or something.

I don’t know enough details, the timing here is a bit unfortunate since we literally have a week-long spring break starting tomorrow :smiley: but when we get back we will look at your specific use case, I’m reasonably sure we can make it work - we just didn’t realize before that it’s a use case that was important to keep working and there were some challenges with the first-class support of generics which was why it got broken. But we’ll try to make it work.

4 Likes

Is typechecking for functions safe? Can we start implementing this? Because I see you guys wrote this feature had bugs (or is it the typechecking+generics)

Some more questions: what’s gonna happen when you try and pass an object/type that is not the object/type the function specifies? Does it throw an error? Does it stop the script?
Also on your git generics are only primitives(???), what does it mean? That it won’t be able to check objects we write? I think if you go with generics it should be able to check for objects/classes/attributes.
On another note, I think GetAllAtributes that were set by players should be a function and could work very well with generics if an object has the same attributes as another for example (not the value of them, but the attributes themselves).

Wait, so you can make your own programming language?

1 Like

Yes, the Luau Type Checking doesn’t break any scripts, it’s there to help the developer.

No, the script simply warns you in the editor that you’re using the incorrect type (which creates visual noise to get your attention).

1 Like

Ahem. ^^ .This post earlier answers your question

1 Like

yeah its actually not too hard once you understand the basics.

1 Like

Oh you’re right I’m so sorry I thought the example needed the new syntax. You can recreate it using typeof.

This is going to be a tricky issue to solve, as backwards compatibility means supporting examples like this of functions returning generic functions that come about due to typeof. Thanks for providing the example, and I’m sorry I didn’t realize its impact yesterday.

In the mean time we’ve switched off the new generic function types, hopefully we’ll be able to reenable them once the issues are sorted out.

4 Likes

You’re not the one who needs to apologize about tone! Sorry my reply to your post was dismissive. There is a real problem here that we need to fix on our end.

5 Likes

Nice. This is a really needed changes.

Wow that is just great! Keep the work up! :+1:

It is nice that you added the debug info function back. However I think maintaining backwards compatibility in this case would be more important as I don’t see that having debug.getinfo be a bit slower would be much of an issue as said functionality would be used quite rarely and there are some advantages of having it as a table as well.

I like the new logo a lot. It is the
Lua logo
lua-language
and the Roblox Logo
image
combined

it looks awesome!

4 Likes