mirror of
https://github.com/luau-lang/luau.git
synced 2025-08-26 11:27:08 +01:00
## General - Support AstStatDeclareGlobal output as a source string (via @karl-police in #1889) - Luau heap dump correctly reports the size of a string, now including overhead for the string type - Prevent yields from Luau `xpcall` error handling function. ## Analysis - Avoid exponential blowup when normalizing union of normalized free variables. - Fix type pack-related bugs that caused infinite recursion when: - A generic type pack was bound to itself during subtyping. - In type pack flattening, when that same generic type pack was now being bound another generic type pack which contained it. - Properly simplify `any & (*error-type* | string)` to `*error-type* | *error-type* | string` instead of hanging due to creating a huge union type. --- Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Menarul Alam <malam@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Vighnesh <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com>
68 lines
No EOL
1.2 KiB
C++
68 lines
No EOL
1.2 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
#include "Luau/DenseHash.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
template<typename T>
|
|
struct OrderedSet
|
|
{
|
|
using iterator = typename std::vector<T>::iterator;
|
|
using const_iterator = typename std::vector<T>::const_iterator;
|
|
|
|
bool empty() const
|
|
{
|
|
return elements.empty();
|
|
}
|
|
|
|
size_t size() const
|
|
{
|
|
return elements.size();
|
|
}
|
|
|
|
void insert(T t)
|
|
{
|
|
if (!elementSet.contains(t))
|
|
{
|
|
elementSet.insert(t);
|
|
elements.push_back(t);
|
|
}
|
|
}
|
|
|
|
iterator begin()
|
|
{
|
|
return elements.begin();
|
|
}
|
|
|
|
const_iterator begin() const
|
|
{
|
|
return elements.begin();
|
|
}
|
|
|
|
iterator end()
|
|
{
|
|
return elements.end();
|
|
}
|
|
|
|
const_iterator end() const
|
|
{
|
|
return elements.end();
|
|
}
|
|
|
|
/// Move the underlying vector out of the OrderedSet.
|
|
std::vector<T> takeVector()
|
|
{
|
|
elementSet.clear();
|
|
return std::move(elements);
|
|
}
|
|
|
|
private:
|
|
std::vector<T> elements;
|
|
DenseHashSet<T> elementSet{nullptr};
|
|
};
|
|
|
|
} // namespace Luau
|