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

Refactor for new solver #783

Merged

Conversation

checkraisefold
Copy link
Contributor

@checkraisefold checkraisefold commented Sep 27, 2024

Todo:

  • Fixed autocompletion
  • Fixed type registration and diagnostics
  • Fixed inlay hints
  • Fixed hover types/documentation
  • Fixed sourcemap

Luau issues worked around:

Blockers:
EDIT: Worked around with magic function
luau-lang/luau#1447 breaks the sourcemap WaitForChild overload registration and causes those tests to fail. I don't see a conceivable workaround for this for now because it causes a type checker error and there is no alternative to the magic function here

Original description:
The new solver has unified autocompletion and diagnostic types. In addition, the nonstrict mode has been significantly improved, meaning #83 has been completely sidestepped. As such, strict datamodel type flags should be ignored with the new solver enabled, and type registration should not occur on globalsForAutocomplete (because it is ignored by Luau).

In addition, loadDefinitionFile and by extension registerBuiltinGlobals, though still taking a typeCheckForAutocomplete argument, that argument no longer does anything within Luau internals, meaning the default to false is safe and it can be removed from explicit use.

Once the new solver is fully stable, the feature flag gates can be removed and this behavior can be the default.

Copy link
Owner

@JohnnyMorganz JohnnyMorganz left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks mostly good to me

In addition, the nonstrict mode has been significantly improved, meaning #83 has been completely sidestepped

I don't think this is completely true. We are now going to trigger false positives again in the new type checker due to mismatched types. What we need to do is implement appropriate read/write types to the generated DataModel types. i.e., the read type should be the more expressive DM type, whilst the write type should be the generic Roblox type, allowing you to correctly read inst.Parent but write anything to it.

src/LuauExt.cpp Show resolved Hide resolved
src/Workspace.cpp Show resolved Hide resolved
Copy link
Owner

@JohnnyMorganz JohnnyMorganz left a comment

Choose a reason for hiding this comment

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

Also can you add some tests to Autocomplete.test.cpp for this?

You might be able to just re-use the existing tests, maybe switch them to use LUAU_BOTH_SOLVERS_TEST_CASE_FIXTURE so that they test with both solvers

@checkraisefold checkraisefold force-pushed the solver-v2-autocomplete-fix branch 3 times, most recently from 650c3a4 to e788b68 Compare September 28, 2024 14:52
@checkraisefold checkraisefold changed the title Fix type registration with new solver Refactor for new solver Sep 30, 2024
@checkraisefold
Copy link
Contributor Author

checkraisefold commented Sep 30, 2024

Thanks for the PR! Looks mostly good to me

In addition, the nonstrict mode has been significantly improved, meaning #83 has been completely sidestepped

I don't think this is completely true. We are now going to trigger false positives again in the new type checker due to mismatched types. What we need to do is implement appropriate read/write types to the generated DataModel types. i.e., the read type should be the more expressive DM type, whilst the write type should be the generic Roblox type, allowing you to correctly read inst.Parent but write anything to it.

I checked and it flat out does not work either way with both examples in #83, but in a different way. There's no warning at all, but the first argument of the connection is *error-type*. So it's actually correctly inferred in both cases and #83 is still side stepped, but a separate issue is causing this:
image

tests/main.cpp Outdated Show resolved Hide resolved
src/DocumentationParser.cpp Outdated Show resolved Hide resolved
@JohnnyMorganz
Copy link
Owner

Also can you add some tests to Autocomplete.test.cpp for this?

Did you end up adding the DataModel types for the new solver? I don't see a test case for it

@checkraisefold
Copy link
Contributor Author

All tests passing woohoo!!!!
🥳 🎉

src/operations/Completion.cpp Outdated Show resolved Hide resolved
src/LuauExt.cpp Outdated Show resolved Hide resolved
src/operations/InlayHints.cpp Outdated Show resolved Hide resolved
@checkraisefold
Copy link
Contributor Author

#806 is a blocker for new solver functionality until it's patched

@checkraisefold
Copy link
Contributor Author

Do not merge - waiting on luau-lang/luau#1495 to remove the hacky mess workaround that is in here
Additionally waiting on luau-lang/luau#1493 to make the roblox def files actually, you know, work instead of being errortype spam, though this isn't a blocker for this PR

CHANGELOG.md Outdated Show resolved Hide resolved
src/operations/Hover.cpp Outdated Show resolved Hide resolved
src/Flags.cpp Outdated Show resolved Hide resolved
@checkraisefold
Copy link
Contributor Author

The tests will fail because you had me split off the InlayHints fix and I feel like flat out turning off the tests is a bad idea

@JohnnyMorganz
Copy link
Owner

@checkraisefold Types smoketest is segfaulting, is this because of the flags? Ideally we don't crash even if the flags are not enabled

@JohnnyMorganz
Copy link
Owner

It actually seems related to the recent luau update to 0.651. Going to undo that sync for now

Copy link
Owner

@JohnnyMorganz JohnnyMorganz left a comment

Choose a reason for hiding this comment

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

Thank you!

@JohnnyMorganz JohnnyMorganz merged commit cba7d65 into JohnnyMorganz:main Nov 9, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants