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

(Fix available in PR) index doesn't wait for pending expansion, luau-analyze crashes on this code from the Forums, stack overflow #1406

Closed
karl-police opened this issue Sep 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@karl-police
Copy link
Contributor

karl-police commented Sep 13, 2024

This post talks about a crash https://devforum.roblox.com/t/new-type-solver-beta/3155804/43

type Keys = index<typeof(PlayerData), keyof<typeof(PlayerData)>>
Full Code is this one:

--!strict

local PlayerData = {
    Coins = 0,
    Level = 1,
    Exp = 0,
    MaxExp = 100
}

type Keys = index<typeof(PlayerData), keyof<typeof(PlayerData)>>

local function UpdateData(key: Keys, value)
    PlayerData[key] = value
    --Remote:FireClient(player, key, value)
end

UpdateData("Coins", 2)

image

@karl-police karl-police added the bug Something isn't working label Sep 13, 2024
@karl-police karl-police changed the title luau-analyze crashes on this code from the Forums luau-analyze crashes on this code from the Forums, stack overflow Sep 13, 2024
@karl-police
Copy link
Contributor Author

I found a fix for this, I believe.

@karl-police karl-police changed the title luau-analyze crashes on this code from the Forums, stack overflow (Fix available in PR) index doesn't wait for pending expansion, luau-analyze crashes on this code from the Forums, stack overflow Sep 13, 2024
@karl-police
Copy link
Contributor Author

Fix is here: #1407

@karl-police
Copy link
Contributor Author

karl-police commented Sep 13, 2024

This fix prevents the crash but there's still this:

However, I think that's the code's fault because the purpose was to cause a crash, and not to fix the type error caused by the modification of non-sense, just to crash.

t1 where t1 = {| [index<t1, keyof<t1>>]: unknown, Coins: number, Exp: number, Level: number, MaxExp: number |}

Here is a proof that it parsed I guess:

https://luau-lang.github.io/dcr-timetraveler/

https://paste.ivr.fi/raw/ramydesobo

aatxe added a commit that referenced this issue Sep 13, 2024
… due to not waiting for a pending-expansion (#1407)

Fix for #1406

While it is good to let ``index`` wait for the pending-expansion. To
re-produce the issue you need more than just this code:
https://i.imgur.com/b3OmUGF.png

It needs this, else it won't crash.

```lua
local function ProblemCauser(key: Keys, value)
    PlayerData[key] = value
end
```

&nbsp;

But regarding "pending things", I'd recommend **generalized functions**
for sanity checks like these, since there will be more cases of similar
issues I believe. But I am 100% sure that eventually this issue here can
maybe be prevented if looking at the Constraints. _(And optimization)_
Not sure if ``index`` needs the table fully completed, or if it is
preferred that the info is available based on **how much info is
available at the current position in the code**.

But if this gets done, I hope that they'll be connected to the Solver
Logger, because I actually refined mine with colors and more info _(yet
need to finish that)_ to understand the Luau Source Code more and to
debug issues.

---------

Co-authored-by: aaron <aweiss@hey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant