Commit Graph

1065 Commits

Author SHA1 Message Date
Vyacheslav Egorov
b5f2813ab4 Merge branch 'upstream' into merge 2024-02-16 03:26:02 +02:00
Vyacheslav Egorov
1778950554 Merge branch 'master' into merge 2024-02-16 03:25:56 +02:00
Vyacheslav Egorov
158d60c223 Sync to upstream/release/613 2024-02-16 03:25:31 +02:00
Andy Friesen
d6c2472f0c
Sync to upstream/release/612 (#1162)
New solver

* Fix bugs where bidirectional type inference would fail to take effect
at the proper stage.
* Improve inference of mutually recursive functions
* Fix crashes

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-02-09 09:51:12 -08:00
Andy Friesen
ffd9f32d2c Merge branch 'upstream' into merge 2024-02-09 09:35:57 -08:00
Andy Friesen
45e72ee97b Merge branch 'master' into merge 2024-02-09 09:33:24 -08:00
Andy Friesen
1a6da94547 Sync to upstream/release/612 2024-02-09 09:32:52 -08:00
Alexander McCord
67ce75e870
Sync to upstream/release/611 (#1160)
# What's changed?

### Native Code Generation

* Fixed an UAF relating to reusing a hash key after a weak table has
undergone some GC.
* Fixed a bounds check on arm64 to allow access to the last byte of a
buffer.

### New Type Solver

* Type states now preserves error-suppression, i.e. `local x: any = 5`
and `x.foo` does not error.
* Made error-suppression logic in subtyping more accurate.
* Subtyping now knows how to reduce type families.
* Fixed function call overload resolution so that the return type
resolves to the correct overload.
* Fixed a case where we attempted to reduce irreducible type families a
few too many times, leading to duplicate errors.
* Type checker needs to type check annotations in function signatures to
be able to report errors relating to those annotations.
* Fixed an UAF from a pointer to stack-allocated data in Subtyping's
`explainReasonings`.

### Nonstrict Type Checker

* Fixed a crash when calling a checked function of the form `math.abs`
with an incorrect argument type.
* Fixed a crash when calling a checked function with a number of
arguments that did not exactly match the number of parameters required.

---

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-02-02 13:32:42 -08:00
Alexander McCord
5559c7fbd5 Fix the stack-use-after-scope. 2024-02-02 13:20:35 -08:00
Alexander McCord
88d2b93351 Merge branch 'heads/upstream' into merge 2024-02-02 10:28:24 -08:00
Alexander McCord
f8f0dd94f7 Merge branch 'master' into merge 2024-02-02 10:20:39 -08:00
Alexander McCord
dfa512ba36 Sync to upstream/release/611 2024-02-02 10:20:03 -08:00
Arseny Kapoulkine
974963a870
Enable newly added M1 GHA CI (#1158)
GitHub just released support for M1 runners for open source projects via
GHA. It can be selected by using macos-14 OS to run on.

This is very valuable because until now, Luau wasn't tested in OSS CI on
Arm64, despite the presence of a fairly large volume of AArch64 specific
code courtesy of A64 codegen. This change fixes that.

In the future we could also expand codecov reporting as it seems to work
well but it needs a little bit of cleanup for the build in question so
let's start small.
2024-02-01 05:18:27 -08:00
Alex Orlenko
d409f7946d
Fix setting sandbox on Lua instance without strlib (#1156)
Currently calling `luaL_sandbox` on Lua instance without loaded strlib
causes crash (assertion).
It happens because inside `luaL_sandbox` there is no check that
metatable for strings is present.
2024-01-30 07:23:58 -08:00
JohnnyMorganz
c0b17daebd
Handle autocomplete in table when no initial character present (#1155)
Closes #685
2024-01-29 09:52:00 -08:00
aaron
9c588be16d
Sync to upstream/release/610 (#1154)
# What's changed?

* Check interrupt handler inside the pattern match engine to eliminate
potential for programs to hang during string library function execution.
* Allow iteration over table properties to pass the old type solver. 

### Native Code Generation

* Use in-place memory operands for math library operations on x64.
* Replace opaque bools with separate enum classes in IrDump to improve
code maintainability.
* Translate operations on inferred vectors to IR.
* Enable support for debugging native-compiled functions in Roblox
Studio.

### New Type Solver

* Rework type inference for boolean and string literals to introduce
bounded free types (bounded below by the singleton type, and above by
the primitive type) and reworked primitive type constraint to decide
which is the appropriate type for the literal.
* Introduce `FunctionCheckConstraint` to handle bidirectional
typechecking for function calls, pushing the expected parameter types
from the function onto the arguments.
* Introduce `union` and `intersect` type families to compute deferred
simplified unions and intersections to be employed by the constraint
generation logic in the new solver.
* Implement support for expanding the domain of local types in
`Unifier2`.
* Rework type inference for iteration variables bound by for in loops to
use local types.
* Change constraint blocking logic to use a set to prevent accidental
re-blocking.
* Add logic to detect missing return statements in functions.

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-01-26 19:20:56 -08:00
Aaron Weiss
ce2665d9f1 Merge branch 'upstream' into merge 2024-01-26 18:31:35 -08:00
Aaron Weiss
e3aba9292e Merge branch 'master' into merge 2024-01-26 18:31:32 -08:00
Aaron Weiss
0edacdded4 Sync to upstream/release/610 2024-01-26 18:30:40 -08:00
vegorov-rbx
cdd1a380db
Sync to upstream/release/609 (#1150)
### What's changed?
* Syntax for [read-only and write-only
properties](https://github.com/luau-lang/rfcs/pull/15) is now parsed,
but is not yet supported in typechecking

### New Type Solver
* `keyof` and `rawkeyof` type operators have been updated to match final
text of the [RFC](https://github.com/luau-lang/rfcs/pull/16)
* Fixed issues with cyclic type families that were generated for mutable
loop variables

### Native Code Generation
* Fixed inference for number / vector operation that caused an
unnecessary VM assist

---
### Internal Contributors
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-01-19 10:04:46 -08:00
Vyacheslav Egorov
2fd3da3c14 Merge branch 'upstream' into merge 2024-01-19 17:17:03 +02:00
Vyacheslav Egorov
59a29fd322 Merge branch 'master' into merge 2024-01-19 17:16:21 +02:00
Vyacheslav Egorov
064d845269 Sync to upstream/release/609 2024-01-19 17:13:08 +02:00
Aleksi
73360e5399
Fix missing include for std::exchange (#1147) 2024-01-16 04:41:40 -08:00
Vighnesh-V
f31232d301
Sync to upstream/release/608 (#1145)
# Old Solver:

- Fix a bug in the old solver where a user could use the keyword
`typeof` as the name of a type alias.
- Fix stringification of scientific notation to omit a trailing decimal
place when not followed by a digit e.g. `1.e+20` -> `1e+20`
# New Solver
- Continuing work on the New non-strict mode
- Introduce `keyof` and `rawkeyof` type function for acquiring the type
of all keys in a table or class
(https://github.com/luau-lang/rfcs/pull/16)

---
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>

---------

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-01-12 14:25:27 -08:00
Vighnesh
38aa074767 resolve memory leak in VecDeque 2024-01-12 14:11:40 -08:00
Vighnesh
2f7509dedd Merge branch 'upstream' into merge 2024-01-12 11:18:51 -08:00
Vighnesh
50b4779798 Sync to upstream/release/608 2024-01-12 11:16:39 -08:00
Vighnesh
79328350ab Merge branch 'upstream' into merge 2024-01-11 22:55:44 -08:00
Vighnesh
74b0d004ec Merge branch 'master' into merge 2024-01-11 22:47:40 -08:00
Vighnesh
0d5c842434 Sync to upstream/release/608 2024-01-11 21:28:14 -08:00
Vighnesh
d4883bfb32 Merge branch 'upstream' of https://github.com/luau-lang/luau into upstream 2024-01-11 14:55:06 -08:00
JohnnyMorganz
c0f5538947
Clone TableType typeLocation (#1136)
This was missed in #1046
2024-01-08 06:25:27 -08:00
vegorov-rbx
e76802f2ce
Add a prefix to TaggedLuData flag to have it auto-enabled in flags ON mode (#1130) 2023-12-15 13:51:14 -08:00
aaron
ff502f0943
Sync to upstream/release/607 (#1131)
# What's changed?

* Fix up the `std::iterator_traits` definitions for some Luau data
structures.
* Replace some of the usages of `std::unordered_set` and
`std::unordered_map` with Luau-provided data structures to increase
performance and reduce overall number of heap allocations.
* Update some of the documentation links in comments throughout the
codebase to correctly point to the moved repository.
* Expanded JSON encoder for AST to support singleton types.
* Fixed a bug in `luau-analyze` where exceptions in the last module
being checked during multithreaded analysis would not be rethrown.

### New type solver

* Introduce a `refine` type family to handle deferred refinements during
type inference, replacing the old `RefineConstraint`.
* Continued work on the implementation of type states, fixing some known
bugs/blockers.
* Added support for variadic functions in new non-strict mode, enabling
broader support for builtins and the Roblox API.

### Internal Contributors

Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-12-15 13:29:06 -08:00
Aaron Weiss
adea0f883c fix ubuntu build with import for cstddef in DenseHash 2023-12-15 13:11:25 -08:00
Aaron Weiss
d6226187b0 Merge branch 'upstream' into merge 2023-12-15 12:53:11 -08:00
Aaron Weiss
89090a16a6 Merge branch 'master' into merge 2023-12-15 12:53:07 -08:00
Aaron Weiss
f9c5cdd4fb Sync to upstream/release/607 2023-12-15 12:52:08 -08:00
Petri Häkkinen
2173938eb0
Add tagged lightuserdata (#1087)
This change adds support for tagged lightuserdata and optional custom
typenames for lightuserdata.

Background: Lightuserdata is an efficient representation for many kinds
of unmanaged handles and resources in a game engine. However, currently
the VM only supports one kind of lightuserdata, which makes it
problematic in practice. For example, it's not possible to distinguish
between different kinds of lightuserdata in Lua bindings, which can lead
to unsafe practices and even crashes when a wrong kind of lightuserdata
is passed to a binding function. Tagged lightuserdata work similarly to
tagged userdata, i.e. they allow checking the tag quickly using
lua_tolightuserdatatagged (or lua_lightuserdatatag).

The tag is stored in the 'extra' field of TValue so it will add no cost
to the (untagged) lightuserdata type.

Alternatives would be to use full userdata values or use bitpacking to
embed type information into lightuserdata on application level.
Unfortunately these options are not that great in practice: full
userdata have major performance implications and bitpacking fails in
cases where full 64 bits are already used (e.g. pointers or 64-bit
hashes).

Lightuserdata names are not strictly necessary but they are rather
convenient when debugging Lua code. More precise error messages and
tostring returning more specific typename are useful to have in practice
(e.g. "resource" or "entity" instead of the more generic "userdata").

Impl note: I did not add support for renaming tags in
lua_setlightuserdataname as I'm not sure if it's possible to free fixed
strings. If it's simple enough, maybe we should allow renaming (although
I can't think of a specific need for it)?

---------

Co-authored-by: Petri Häkkinen <petrih@rmd.remedy.fi>
2023-12-14 15:05:51 -08:00
vegorov-rbx
c26d820902
Sync to upstream/release/606 (#1127)
New Solver
* Improvements to data flow analysis

Native Code Generation
* Block limit is now per-function instead of per-module

Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-12-08 13:50:16 -08:00
Vyacheslav Egorov
139b169361 Merge fix 2023-12-08 17:58:25 +02:00
Vyacheslav Egorov
6068432285 Merge branch 'upstream' into merge 2023-12-08 17:47:11 +02:00
Vyacheslav Egorov
f5441d7030 Merge branch 'master' into merge 2023-12-08 17:46:40 +02:00
Vyacheslav Egorov
69728e87cf Sync to upstream/release/606 2023-12-08 17:42:54 +02:00
Vighnesh-V
2ea7193777
Resolve RequireByString test suite failures on Ubuntu CI (#1124)
This PR resolves the RequireByString test suite failures in CI on
Ubuntu. The issue was that paths on linux are case sensitive and thus
MacOS/Windows machines simply behaved as if the paths to the test files
were case-insensitive, but the linux machine was unable to find the test
files. Those tests were `#ifdef'd` out, and have been un `#ifdef'd` to
demonstrate these changes work.
2023-12-05 14:31:02 -08:00
Vyacheslav Egorov
aafea36235
Fixed the backwards compatible benchmark support library require (#1125)
Previous benchmark require fix wasn't actually working correctly for the
old style require (or running in Lua).
2023-12-04 12:48:31 -08:00
menarulalam
765ac75fe9
Update ExperimentalFlags.h (#1123)
Add LuauUpdatedRequireByStringSemantics to experimental flags.
2023-12-04 14:26:39 -05:00
Vyacheslav Egorov
ce1800746b
Fix 'require' in benchmarks to work with new relative system (#1120)
Old style require is now called with `pcall` to support comparing
against Lua.
New style require is now a third option.

Edit: this will be a temporary solution until the 'paths' support in
.luaurc is fixed.
2023-12-02 14:20:54 -08:00
Vyacheslav Egorov
6413ea8574
Only build fuzzer with CMake if 3.26 is available (#1119)
`cmake_minimum_required` is a blocking check and raising required
minimal CMake version only for the fuzzer is not good for the users
(<3.19 was supported before, but not sure which exact one)
2023-12-02 13:04:25 -08:00