mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:47:35 +00:00
LibJS: Remove Object(Object& prototype) footgun
This constructor was easily confused with a copy constructor, and it was possible to accidentally copy-construct Objects in at least one way that we dicovered (via generic ThrowCompletionOr construction). This patch adds a mandatory ConstructWithPrototypeTag parameter to the constructor to disambiguate it.
This commit is contained in:
parent
42b5c896e8
commit
4abdb68655
90 changed files with 100 additions and 99 deletions
|
@ -28,7 +28,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 12 Temporal.Calendar Objects, https://tc39.es/proposal-temporal/#sec-temporal-calendar-objects
|
||||
Calendar::Calendar(DeprecatedString identifier, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_identifier(move(identifier))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 7 Temporal.Duration Objects, https://tc39.es/proposal-temporal/#sec-temporal-duration-objects
|
||||
Duration::Duration(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_years(years)
|
||||
, m_months(months)
|
||||
, m_weeks(weeks)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 8 Temporal.Instant Objects, https://tc39.es/proposal-temporal/#sec-temporal-instant-objects
|
||||
Instant::Instant(BigInt const& nanoseconds, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_nanoseconds(nanoseconds)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 2 The Temporal.Now Object, https://tc39.es/proposal-temporal/#sec-temporal-now-object
|
||||
Now::Now(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 3 Temporal.PlainDate Objects, https://tc39.es/proposal-temporal/#sec-temporal-plaindate-objects
|
||||
PlainDate::PlainDate(i32 year, u8 month, u8 day, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(year)
|
||||
, m_iso_month(month)
|
||||
, m_iso_day(day)
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 5 Temporal.PlainDateTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-objects
|
||||
PlainDateTime::PlainDateTime(i32 iso_year, u8 iso_month, u8 iso_day, u8 iso_hour, u8 iso_minute, u8 iso_second, u16 iso_millisecond, u16 iso_microsecond, u16 iso_nanosecond, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(iso_year)
|
||||
, m_iso_month(iso_month)
|
||||
, m_iso_day(iso_day)
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 10 Temporal.PlainMonthDay Objects, https://tc39.es/proposal-temporal/#sec-temporal-plainmonthday-objects
|
||||
PlainMonthDay::PlainMonthDay(u8 iso_month, u8 iso_day, i32 iso_year, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(iso_year)
|
||||
, m_iso_month(iso_month)
|
||||
, m_iso_day(iso_day)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 4 Temporal.PlainTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-plaintime-objects
|
||||
PlainTime::PlainTime(u8 iso_hour, u8 iso_minute, u8 iso_second, u16 iso_millisecond, u16 iso_microsecond, u16 iso_nanosecond, Calendar& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_hour(iso_hour)
|
||||
, m_iso_minute(iso_minute)
|
||||
, m_iso_second(iso_second)
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 9 Temporal.PlainYearMonth Objects, https://tc39.es/proposal-temporal/#sec-temporal-plainyearmonth-objects
|
||||
PlainYearMonth::PlainYearMonth(i32 iso_year, u8 iso_month, u8 iso_day, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_iso_year(iso_year)
|
||||
, m_iso_month(iso_month)
|
||||
, m_iso_day(iso_day)
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
|
||||
Temporal::Temporal(Realm& realm)
|
||||
: Object(*realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 11 Temporal.TimeZone Objects, https://tc39.es/proposal-temporal/#sec-temporal-timezone-objects
|
||||
TimeZone::TimeZone(Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace JS::Temporal {
|
|||
|
||||
// 6 Temporal.ZonedDateTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-zoneddatetime-objects
|
||||
ZonedDateTime::ZonedDateTime(BigInt const& nanoseconds, Object& time_zone, Object& calendar, Object& prototype)
|
||||
: Object(prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_nanoseconds(nanoseconds)
|
||||
, m_time_zone(time_zone)
|
||||
, m_calendar(calendar)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue