Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Setup basic Luau analysis #372

Merged
merged 21 commits into from
Jun 10, 2022
Merged

Setup basic Luau analysis #372

merged 21 commits into from
Jun 10, 2022

Conversation

ghostnaps
Copy link
Contributor

@ghostnaps ghostnaps commented Jun 9, 2022

This sets up the repo with Luau analysis and fixes the initial type errors

Checklist before submitting:

  • Added entry to CHANGELOG.md
  • Added/updated relevant tests
  • Added/updated documentation

@coveralls
Copy link

coveralls commented Jun 9, 2022

Coverage Status

Coverage increased (+0.07%) to 94.857% when pulling 923af16 on ghostnaps:basic-luau-analysis into 2909222 on Roblox:master.

@github-actions
Copy link

github-actions bot commented Jun 9, 2022

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@ghostnaps ghostnaps marked this pull request as ready for review June 9, 2022 22:24
Copy link
Contributor

@matthargett matthargett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Some minor suggestions.

@@ -6,7 +6,7 @@
This should only be used in tests.
]]

local function deepEqual(a, b)
local function deepEqual(a, b): (boolean, string?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also work and more precisely express the scenarios:

Suggested change
local function deepEqual(a, b): (boolean, string?)
local function deepEqual(a, b): (true, nil) | (false, string)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had no idea we could use boolean literals. Awesome!

@@ -19,7 +19,7 @@ local function deepEqual(a, b)
visitedKeys[key] = true

local success, innerMessage = deepEqual(value, b[key])
if not success then
if not success and innerMessage then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there's a narrowing bug lingering, using the above type suggestion should eliminate the needs for these extra checks. If it doesn't, add a -- FIXME Luau comment and we can help file a Luau issue.

src/createReconciler.spec.lua Show resolved Hide resolved
src/strict.lua Show resolved Hide resolved
@@ -134,7 +134,7 @@ function BindingInternalApi.join(upstreamBindings)
disconnect()
end

disconnects = nil
disconnects = nil :: any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to make the delcaration of disconnects have an explicit type that includes nil (eg local disconnects: Array<any> | nil = {}). (Once deferred constraint resolution and some other Luau features land, it will not longer greedily assume the first assignment it sees is the only type possibility for the whole closure.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads to issues with indexing the disconnects variable since Luau now thinks it could be nil at any point. I think it would be a bit overkill to check if disconnects then so maybe we should just stick with casting to any

Screen Shot 2022-06-10 at 11 41 59 AM

src/Component.lua Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
@ghostnaps
Copy link
Contributor Author

Got a few analysis errors left from enabling strict mode in createReconsiler. My Luau knowledge is run up against a wall here so I would appreciate somebody taking a pass to clean up these remaining issues

@ZoteTheMighty
Copy link
Contributor

This is a good start towards type strictness! Thanks for introducing the tooling as well.

@ZoteTheMighty ZoteTheMighty merged commit 82b805a into Roblox:master Jun 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants