Commit graph

1075 commits

Author SHA1 Message Date
Lily Brown
8237b2f593 Sync to upstream/release/601 2023-10-27 12:33:36 -07:00
Arseny Kapoulkine
87d955d5eb Fix remaining references to Roblox org outside of source code 2023-10-24 10:32:59 -07:00
Arseny Kapoulkine
88fcbd58e6
Update README.md
Fix status badges and various repository links
2023-10-24 10:28:19 -07:00
Arseny Kapoulkine
ff59ced5ee
Delete docs directory
The directory was moved to https://github.com/luau-lang/site

See #1074 for context
2023-10-24 10:22:54 -07:00
Maciej Barć
26f79951f7
TypePairHash.h: include cstdint (#1078)
luau fails to compile w/o this on Gentoo

Signed-off-by: Maciej Barć <xgqt@gentoo.org>
2023-10-24 10:02:46 -07:00
Arseny Kapoulkine
13e3af2724
Delete papers directory
The directory was moved to https://github.com/luau-lang/research

See https://github.com/Roblox/luau/issues/1074 for context
2023-10-23 09:02:08 -07:00
Arseny Kapoulkine
d70a02a2d0
Delete CNAME 2023-10-23 08:57:58 -07:00
Micah
011c1afbde
Implement bit32.byteswap (#1075)
I've decided to take a stab at implementing `bit32.byteswap` from the
[recently merged
RFC](https://github.com/Roblox/luau/blob/master/rfcs/function-bit32-byteswap.md).
I asked on Discord for some guidance, but for the sake of posterity:
this is my first time doing this and I am likely to have made some
mistakes.

The biggest gaps in this implementation are the lack of tests and the
lack of native codegen support. I'd appreciate help with those since I'm
not sure what's relevant for me to touch for tests, and I'm told that
relevant assembler instructions don't exist publicly yet. Intuition
tells me that Luau-side tests would go into
`tests/conformance/bitwise.luau` but this is not well documented and I'm
not sure how I'm meant to test built-in implementations.

The current implementation compiles down to `bswap` and `rev` on x86 and
ARM respectively when optimized.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
2023-10-23 08:00:48 -07:00
Vighnesh-V
fd6250cf9d
Sync to upstream/release/600 (#1076)
### What's Changed

- Improve readability of unions and intersections by limiting the number
of elements of those types that can be presented on a single line (gated
under `FFlag::LuauToStringSimpleCompositeTypesSingleLine`)
- Adds a new option to the compiler `--record-stats` to record and
output compilation statistics
- `if...then...else` expressions are now optimized into `AND/OR` form
when possible.

### VM

- Add a new `buffer` type to Luau based on the [buffer
RFC](https://github.com/Roblox/luau/pull/739) and additional C API
functions to work with it; this release does not include the library.
- Internal C API to work with string buffers has been updated to align
with Lua version more closely

### Native Codegen

- Added support for new X64 instruction (rev) and new A64 instruction
(bswap) in the assembler
- Simplified the way numerical loop condition is translated to IR

### New Type Solver

- Operator inference now handled by type families
- Created a new system called `Type Paths` to explain why subtyping
tests fail in order to improve the quality of error messages.
- Systematic changes to implement Data Flow analysis in the new solver
(`Breadcrumb` removed and replaced with `RefinementKey`)

---
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: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
2023-10-20 18:10:30 -07:00
Vighnesh
46f18bb352 comment out whole test case 2023-10-20 17:37:59 -07:00
Vighnesh
43915a4675 More test uncommenting 2023-10-20 17:07:09 -07:00
Vighnesh
7602c43214 Disable failing tests that rely on type paths 2023-10-20 16:09:58 -07:00
Vighnesh
8002cbb125 Merge branch 'upstream' into merge
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: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-10-20 14:02:26 -07:00
Vighnesh
6e91ab9227 Merge branch 'master' into merge 2023-10-20 13:37:59 -07:00
Vighnesh
897a5da14e Sync to upstream/release/600 2023-10-20 13:36:26 -07:00
Rerumu
380bb7095d
RFC: Built in buffer type and library (#739)
[Rendered
document](https://github.com/Rerumu/luau/blob/rfc-type-byte-array/rfcs/type-byte-buffer.md).

---------

Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Micah <dekkonot@rocketmail.com>
2023-10-19 01:13:58 -07:00
Arseny Kapoulkine
61afc5e0dd
Create CNAME 2023-10-16 16:25:47 -07:00
Arseny Kapoulkine
cb59964bda
Delete CNAME 2023-10-16 16:25:28 -07:00
Alexander McCord
6439719cd2
Facelift of the Account OO example. (#578)
When the original version was written, bidirectional type inference
didn't exist, so this new kind of pattern was simply not possible.

Now that it does, we can stop telling users to use the original typeof
workaround.

The only thing that's a bit unfortunate is the cast of `{}` into
`AccountImpl`, but it's a necessary evil for now until we get a few more
big ticket items. When we have that, we can likely kill the cast and
call it redundant.
2023-10-16 16:06:53 -07:00
Micah
7e5643a4ad
RFC: Add bit32.byteswap to support swapping the endianness of integers (#1052)
This function might be of particular use if #739 is accepted, but as it
stands, it still brings a measurable reduction in complexity for
swapping byte order and is measurably faster (around a 50% reduction in
time per operation on my machine), albeit on the order of magnitude of
nanoseconds.
2023-10-16 08:47:23 -07:00
Lily Brown
24fdac4c05
Sync to upstream/release/599 (#1069)
## What's Changed

- Improve POSIX compliance in `CLI/FileUtils.cpp` by @SamuraiCrow #1064
- `AstStat*::hasEnd` is deprecated; use `AstStatBlock::hasEnd` instead
- Added a lint for common misuses of the `#` operator
- Luau now issues deprecated diagnostics for some uses of `getfenv` and
`setfenv`
- Fixed a case where we included a trailing space in some error
stringifications

### Compiler

- Do not do further analysis in O2 on self functions
- Improve detection of invalid repeat..until expressions vs continue

### New Type Solver

- We now cache subtype test results to improve performance
- Improved operator inference mechanics (aka type families)
- Further work towards type states
- Work towards [new non-strict
mode](https://github.com/Roblox/luau/blob/master/rfcs/new-nonstrict.md)
continues

### Native Codegen

- Instruction last use locations should follow the order in which blocks
are lowered
- Add a bonus assertion to IrLoweringA64::tempAddr

---

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
2023-10-13 13:20:12 -07:00
Lily Brown
dc6a75b450 Merge branch 'upstream' into merge 2023-10-13 12:43:34 -07:00
Lily Brown
4d2be9727e Merge remote-tracking branch 'origin/master' into merge 2023-10-13 12:42:29 -07:00
Lily Brown
34efdb3b0a Sync to upstream/release/599 2023-10-13 12:38:31 -07:00
Alex Orlenko
5c94984935
Add lua_getallocf API function (#1068)
This function matches the corresponding Lua 5.1-5.4 function:

[`lua_getallocf`](https://www.lua.org/manual/5.4/manual.html#lua_getallocf)
and [source](https://www.lua.org/source/5.4/lapi.c.html#lua_getallocf)

It would be useful to get/manipulate auxiliary "userdata" pointer that was originally passed to `lua_newstate`.
2023-10-13 08:47:33 -07:00
JohnnyMorganz
1173e415ef
Modify the way line breaks are added when printing unions/intersections (#1047)
Adds an option `compositeTypesSingleLineLimit` to control when
unions/intersections are broken up onto multiple lines when printed.
Simple unions/intersections will remain on one line. Default value is
set to `5`.

I took the liberty to always expand overloaded function intersections on
multiple lines, as I believe they are best viewed that way, even if
theres only 2 functions.

Closes #963
2023-10-12 09:09:47 -07:00
Samuel Crow
984336448c
Improve POSIX compliance in CLI/FileUtils.cpp (#1064)
Some POSIX platforms, such as Haiku and some BSDs, don't supply DT_*
identifiers and the corresponding d_type field in stat. This fixes that
and has been tested to still work on 64-bit Linux as well as 64-bit
Haiku.
2023-10-12 05:46:53 -07:00
Arseny Kapoulkine
3d4e99fc6c rfcs: Update status
String interpolation and table.getn/et al deprecation has been live for
a while.

getfenv/setfenv linter diagnostics is going to ship in the next release,
so preemptively marking this as Implemented as well.
2023-10-11 08:29:25 -07:00
Alan Jeffrey
497dd1bad4
Incorrectness 2024 paper (#1048) 2023-10-09 19:00:31 -05:00
Alan Jeffrey
ffc28da331
RFC for new non-strict mode (#1037) 2023-10-09 18:57:50 -05:00
Andy Friesen
36e0e64715
Sync to upstream/release/598 (#1063)
* Include `windows.h` rather than `Windows.h` to make things compile on
MinGW.
* Custom implementation of timegm/os.time for all platforms
* Disable builtin constant folding when getfenv/setfenv are used
* Fixes https://github.com/Roblox/luau/issues/1042
* Fixes https://github.com/Roblox/luau/issues/1043

New Type Checker

* Initial work toward type states.
* Rework most overloadable operators to use type families.
* Initial work toward our new nonstrict mode.


Native Codegen

* Fix native code generation for dead loops
* Annotate top-level functions as cold
* Slightly smaller/faster x64 Luau calls
* emitInstCall used to not set savedpc itself, but now it does for
consistency with all other implementations
* Implement cmov support for X64
* Fix assertion in luau-compile when module is empty
* Optimize A64 calls at some code size cost
* Inline constant array index offset into the load/store instruction
* Increase x64 spill slots from 5 to 13

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Alexander McCord <amccord@roblox.com>
2023-10-06 12:02:32 -07:00
Andy Friesen
ff9c57255c Turn this down a little temporarily. We'll sort out the root cause later. 2023-10-06 11:39:08 -07:00
Andy Friesen
008b77a09a Merge branch 'upstream' into merge 2023-10-06 10:40:24 -07:00
Andy Friesen
47374ff2a6 Merge branch 'master' into merge 2023-10-06 10:36:16 -07:00
Andy Friesen
22e3d1fa46 Sync to upstream/release/598 2023-10-06 10:31:16 -07:00
Arseny Kapoulkine
225a4a0870
Update compatibility.md (#1059)
Add a note about Lua 5.3 change to semantics of __eq metamethod.

We currently do not plan to implement this as this breaks backwards
compatibility and makes these operators harder to reason about from the
type checking perspective.

Fixes #1051.
2023-10-03 07:39:48 -07:00
Radiant
2a3a030341
Rename Windows.h to windows.h (#1055)
Make it able to compile on MingW

Fixes #873.

Co-authored-by: Radiant <i.like.using.discord@gmail.com>
2023-10-03 06:59:44 -07:00
Alexander McCord
1d0b449181
Sync to upstream/release/597 (#1054)
# New Type Solver

- Implement bidirectional type inference for higher order functions so
that we can provide a more precise type improving the autocomplete's
human factors.
- We seal all tables, so we changed the stringification to make it a
little lighter on users.
- Fixed a case of array-out-of-bound access.
- Type families no longer depends on `TxnLog` and `Unifier`.
- Type refinements now waits until the free types are sufficiently
solved.

# Native Code Generation

- Remove cached slot lookup for `executeSETTABLEKS` function because it
is a fallback in the event of a cache miss, making the cached slot
lookup redundant.
- Optimized repeated array lookups, e.g. `a[3]` in `a[3] = a[3] / 2` is
done once.

# Misc

- On some platforms, it is necessary to use `gmtime_s` with the
arguments reversed to get the current time. You can now define
`DOCTEST_CONFIG_USE_GMTIME_S` to build and run unit tests on those
platforms.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
2023-09-29 18:13:05 -07:00
Alexander McCord
d42188a2da Merge branch 'heads/upstream' into merge 2023-09-29 17:25:41 -07:00
Alexander McCord
c6b581addc Merge branch 'master' into merge 2023-09-29 17:23:20 -07:00
Alexander McCord
3bfc864280 Sync to upstream/release/597 2023-09-29 17:22:06 -07:00
aaron
16fbfe912c
Sync to upstream/release/596 (#1050)
- Cleaned up `FFlag::FixFindBindingAtFunctionName`,
`FFlag::LuauNormalizeBlockedTypes`, `FFlag::LuauPCallDebuggerFix`
- Added support for break and continue into control flow analysis
- The old type unification engine will now report a more fine-grained
error at times, indicating that type normalization in particular failed

# New Type Solver

- Refactor of Unifier2, the new unification implementation for Luau
- Completed MVP of new unification implementation
- Dramatically simplified overload selection logic
- Type family reduction can now apply sooner to free types that have
been solved
- Subtyping now supports table indexers
- Generalization now replaces bad generics with unknown

# Native Code Generation

- Reduce stack spills caused by FINDUPVAL and STORE_TAG
- Improve Generate SHL/SHR/SAR/rotates with immediate operands in X64
- Removed redundant case re-check in table lookup fallback

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
2023-09-22 12:12:15 -07:00
Aaron Weiss
3882ab1488 Merge branch 'upstream' into merge 2023-09-22 11:12:50 -07:00
Aaron Weiss
d4de6f7502 Merge branch 'master' into merge 2023-09-22 11:12:44 -07:00
Aaron Weiss
81681e2948 Sync to upstream/release/596 2023-09-22 11:10:49 -07:00
Amber Grace
d00e93c82c
Support Control Flow type Refinements for "break" and "continue" statements (#1004)
Fixes: https://github.com/Roblox/luau/issues/913

This PR adds support for type refinements around guard clauses that use
`break` and `continue` statements inside a loop, similar to how guard
clauses with `return` is supported.

I had some free time today, so I figure I'd give a shot at a naïve fix
for this at the very least.

---

## Resulting Change:

Luau now supports type refinements within loops where a `continue` or
`break` guard clause was used.
For example:
```lua
for _, object in objects :: {{value: string?}} do
    if not object.value then
        continue
    end
    local x: string = object.value -- OK; Used to emit "Type 'string?' could not be converted into 'string'"
end
```

---------

Co-authored-by: Alexander McCord <amccord@roblox.com>
2023-09-21 15:28:42 -07:00
Arseny Kapoulkine
309001020a
Update benchmark.yml
Update apt-get cache before installing valgrind as it looks like the default cache got out of date.
2023-09-16 12:21:09 +02:00
Andy Friesen
31a017c5c7
Sync to upstream/release/595 (#1044)
* Rerun clang-format on the code
* Fix the variance on indexer result subtyping. This fixes some issues
with inconsistent error reporting.
* Fix a bug in the normalization logic for intersections of strings

New Type Solver

* New overload selection logic
* Subtype tests now correctly treat a generic as its upper bound within
that generic's scope
* Semantic subtyping for negation types
* Semantic subtyping between strings and compatible table types like
`{lower: (string) -> string}`
* Further work toward finalizing our new subtype test
* Correctly generalize module-scope symbols

Native Codegen

* Lowering statistics for assembly
* Make executable allocation size/limit configurable without a rebuild.
Use `FInt::LuauCodeGenBlockSize` and `FInt::LuauCodeGenMaxTotalSize`.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
2023-09-15 10:26:59 -07:00
Andy Friesen
c0449320f0 Merge branch 'upstream' into merge 2023-09-15 09:28:12 -07:00
Andy Friesen
55d7a9912d Merge branch 'master' into merge 2023-09-15 09:28:09 -07:00