mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 13:00:38 +00:00
ae459a0197
# What's Changed * Add a compiler hint to improve Luau memory allocation inlining ### New Type Solver * Added a system for recommending explicit type annotations to users in cases where we've inferred complex generic types with type families. * Marked string library functions as `@checked` for use in new non-strict mode. * Fixed a bug with new non-strict mode where we would incorrectly report arity mismatches when missing optional arguments. * Implement an occurs check for unifications that would produce self-recursive types. * Fix bug where overload resolution would fail when applied to non-overloaded functions. * Fix bug that caused the subtyping to report an error whenever a generic was instantiated in an invariant context. * Fix crash caused by `SetPropConstraint` not blocking properly. ### Native Code Generation * Implement optimization to eliminate dead stores * Optimize vector ops for X64 when the source is computed (thanks, @zeux!) * Use more efficient lowering for UNM_* (thanks, @zeux!) --- ### 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: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@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>
52 lines
1 KiB
C++
52 lines
1 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 "Luau/Common.h"
|
|
|
|
#include <string.h>
|
|
|
|
template<typename T>
|
|
struct [[nodiscard]] ScopedFValue
|
|
{
|
|
private:
|
|
Luau::FValue<T>* value = nullptr;
|
|
T oldValue = T();
|
|
|
|
public:
|
|
ScopedFValue(Luau::FValue<T>& fvalue, T newValue)
|
|
{
|
|
value = &fvalue;
|
|
oldValue = fvalue.value;
|
|
fvalue.value = newValue;
|
|
}
|
|
|
|
ScopedFValue(const ScopedFValue&) = delete;
|
|
ScopedFValue& operator=(const ScopedFValue&) = delete;
|
|
|
|
ScopedFValue(ScopedFValue&& rhs)
|
|
{
|
|
value = rhs.value;
|
|
oldValue = rhs.oldValue;
|
|
|
|
rhs.value = nullptr;
|
|
}
|
|
|
|
ScopedFValue& operator=(ScopedFValue&& rhs)
|
|
{
|
|
value = rhs.value;
|
|
oldValue = rhs.oldValue;
|
|
|
|
rhs.value = nullptr;
|
|
|
|
return *this;
|
|
}
|
|
|
|
~ScopedFValue()
|
|
{
|
|
if (value)
|
|
value->value = oldValue;
|
|
}
|
|
};
|
|
|
|
using ScopedFastFlag = ScopedFValue<bool>;
|
|
using ScopedFastInt = ScopedFValue<int>;
|