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

a = a :: type should be free. #793

Closed
ghost opened this issue Jan 3, 2023 · 2 comments · Fixed by #796
Closed

a = a :: type should be free. #793

ghost opened this issue Jan 3, 2023 · 2 comments · Fixed by #796
Assignees
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Jan 3, 2023

Right now, code such as

local function(a: number?)
  a = a :: number
end

will generate an unneccessary bytecode operation, the code above generates MOVE R0 R0 which is redundant.

@ghost ghost added the enhancement New feature or request label Jan 3, 2023
@vegorov-rbx vegorov-rbx self-assigned this Jan 3, 2023
@vegorov-rbx
Copy link
Collaborator

Extra info - same happens without type assertion:

local function f(a: number?)
  a = a
end

@vegorov-rbx
Copy link
Collaborator

We should have a fix for this soon.

vegorov-rbx added a commit that referenced this issue Jan 6, 2023
* Fixed garbage data in module scopes when type graph is not retained
* LOP_MOVE with the same source and target registers is no longer
generated (Fixes #793)
RomanKhafizianov pushed a commit to RomanKhafizianov/luau that referenced this issue Nov 27, 2023
* Fixed garbage data in module scopes when type graph is not retained
* LOP_MOVE with the same source and target registers is no longer
generated (Fixes luau-lang/luau#793)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

1 participant