Skip to content

Commit

Permalink
fix(coverage): apply always_strict to test262 and typescript
Browse files Browse the repository at this point in the history
This also removes the confusing `SourceType::always_strict` field.
  • Loading branch information
Boshen committed Sep 6, 2024
1 parent b060525 commit 29a2ced
Show file tree
Hide file tree
Showing 9 changed files with 15,792 additions and 15,757 deletions.
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ const _: () = {
assert!(offset_of!(Span, start) == 0usize);
assert!(offset_of!(Span, end) == 4usize);

assert!(size_of::<SourceType>() == 4usize);
assert!(size_of::<SourceType>() == 3usize);
assert!(align_of::<SourceType>() == 1usize);

assert!(size_of::<Language>() == 1usize);
Expand Down Expand Up @@ -2954,7 +2954,7 @@ const _: () = {
assert!(offset_of!(Span, start) == 0usize);
assert!(offset_of!(Span, end) == 4usize);

assert!(size_of::<SourceType>() == 4usize);
assert!(size_of::<SourceType>() == 3usize);
assert!(align_of::<SourceType>() == 1usize);

assert!(size_of::<Language>() == 1usize);
Expand Down
17 changes: 2 additions & 15 deletions crates/oxc_span/src/source_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ impl SourceType {
language: Language::JavaScript,
module_kind: ModuleKind::Script,
variant: LanguageVariant::Standard,
always_strict: false,
}
}

Expand Down Expand Up @@ -110,7 +109,6 @@ impl SourceType {
language: Language::TypeScript,
module_kind: ModuleKind::Module,
variant: LanguageVariant::Standard,
always_strict: false,
}
}

Expand Down Expand Up @@ -150,7 +148,6 @@ impl SourceType {
language: Language::TypeScriptDefinition,
module_kind: ModuleKind::Module,
variant: LanguageVariant::Standard,
always_strict: false,
}
}

Expand Down Expand Up @@ -185,12 +182,8 @@ impl SourceType {
self.variant == LanguageVariant::Jsx
}

pub fn always_strict(self) -> bool {
self.always_strict
}

pub fn is_strict(self) -> bool {
self.is_module() || self.always_strict
self.is_module()
}

#[must_use]
Expand Down Expand Up @@ -235,12 +228,6 @@ impl SourceType {
self
}

#[must_use]
pub const fn with_always_strict(mut self, yes: bool) -> Self {
self.always_strict = yes;
self
}

/// Converts a file [`Path`] to [`SourceType`].
///
/// ## Examples
Expand Down Expand Up @@ -329,7 +316,7 @@ impl SourceType {
_ => LanguageVariant::Standard,
};

Ok(Self { language, module_kind, variant, always_strict: false })
Ok(Self { language, module_kind, variant })
}
}

Expand Down
7 changes: 1 addition & 6 deletions crates/oxc_span/src/source_type/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use oxc_ast_macros::ast;
#[cfg(feature = "serialize")]
use ::{serde::Serialize, tsify::Tsify};
use {serde::Serialize, tsify::Tsify};

/// Source Type for JavaScript vs TypeScript / Script vs Module / JSX
#[ast]
Expand All @@ -19,11 +19,6 @@ pub struct SourceType {

/// Support JSX for JavaScript and TypeScript? default without JSX
pub(super) variant: LanguageVariant,

/// Mark strict mode as always strict
///
/// See <https://github.com/tc39/test262/blob/main/INTERPRETING.md#strict-mode>
pub(super) always_strict: bool,
}

/// JavaScript or TypeScript
Expand Down
Loading

0 comments on commit 29a2ced

Please sign in to comment.