Skip to content

Commit

Permalink
Rename property, fix clippy and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleidawave committed Feb 8, 2025
1 parent 0235c11 commit 0d65135
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/performance-and-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
packages: hyperfine ripgrep

- name: Install valgrind
id: install-valgrind
continue-on-error: true
run: sudo apt-get install valgrind

- name: Get last run
Expand Down Expand Up @@ -180,6 +182,7 @@ jobs:
- name: Valgrind and callgrind
shell: bash
if: ${{ steps.install-valgrind.outcome == 'success' }}
continue-on-error: true
run: |
IFS=',' read -ra ITEMS <<< ${{ steps.compilers.outputs.BINARIES }}
Expand Down
6 changes: 3 additions & 3 deletions checker/src/synthesis/type_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ pub fn synthesise_type_annotation<T: crate::ReadFromFS>(

for TupleLiteralElement(spread, member, pos) in members {
let annotation_ty =
synthesise_type_annotation(&member.ty, environment, checking_data);
synthesise_type_annotation(&member.type_annotation, environment, checking_data);

let pos = pos.with_source(environment.get_source());

Expand Down Expand Up @@ -660,11 +660,11 @@ pub fn synthesise_type_annotation<T: crate::ReadFromFS>(
};
// WIP fix correcting `infer T` to `infer T extends string` so that string addition works
let rhs = if let TypeAnnotation::Infer { name, extends: None, position: _ } =
&dynamic_part.ty
&dynamic_part.type_annotation
{
environment.new_infer_type(TypeId::STRING_TYPE, name, &mut checking_data.types)
} else {
synthesise_type_annotation(&dynamic_part.ty, environment, checking_data)
synthesise_type_annotation(&dynamic_part.type_annotation, environment, checking_data)
};
let constructor = crate::types::Constructor::BinaryOperator {
lhs: acc,
Expand Down
2 changes: 1 addition & 1 deletion parser/src/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<T: FunctionBased + 'static> ASTNode for FunctionBase<T> {
}
// Don't print overloads
#[cfg(feature = "full-typescript")]
if T::has_body(&self.body) {
if !T::has_body(&self.body) {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion parser/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ pub(crate) mod utilities {
&reader.get_current()[item.len()..]
}

pub fn after_brackets<'a>(current: &'a str) -> &'a str {
pub fn after_brackets(current: &str) -> &str {
use crate::Quoted;

enum State {
Expand Down
34 changes: 21 additions & 13 deletions parser/src/types/type_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl ListItem for TypeAnnotation {
#[apply(derive_ASTNode)]
pub struct AnnotationWithBinder {
pub name: Option<String>,
pub ty: TypeAnnotation,
pub type_annotation: TypeAnnotation,
pub position: Span,
}

Expand All @@ -142,8 +142,8 @@ impl ASTNode for AnnotationWithBinder {
} else {
None
};
let ty = TypeAnnotation::from_reader(reader)?;
Ok(AnnotationWithBinder { position: start.union(reader.get_end()), name, ty })
let type_annotation = TypeAnnotation::from_reader(reader)?;
Ok(AnnotationWithBinder { position: start.union(reader.get_end()), name, type_annotation })
}

fn to_string_from_buffer<T: source_map::ToString>(
Expand All @@ -156,7 +156,7 @@ impl ASTNode for AnnotationWithBinder {
buf.push_str(name);
buf.push_str(": ");
}
self.ty.to_string_from_buffer(buf, options, local);
self.type_annotation.to_string_from_buffer(buf, options, local);
}
}

Expand Down Expand Up @@ -193,7 +193,7 @@ impl ASTNode for BinderWithAnnotation {
self.name.to_string_from_buffer(buf, options, local);
if let Some(ty) = &self.ty {
buf.push_str(": ");
ty.to_string_from_buffer(buf, options, local)
ty.to_string_from_buffer(buf, options, local);
}
}
}
Expand Down Expand Up @@ -1183,16 +1183,20 @@ mod tests {
TypeAnnotation::TupleLiteral(
Deref @ [TupleLiteralElement(
TupleElementKind::Standard,
AnnotationWithBinder::NoAnnotation(TypeAnnotation::CommonName(
CommonTypes::Number,
span!(1, 7),
)),
AnnotationWithBinder {
type_annotation: TypeAnnotation::CommonName(
CommonTypes::Number,
span!(1, 7),
),
name: None,
position: _,
},
_,
), TupleLiteralElement(
TupleElementKind::Standard,
AnnotationWithBinder::Annotated {
name: Deref @ "x",
ty: TypeAnnotation::CommonName(CommonTypes::String, span!(12, 18)),
AnnotationWithBinder {
name: Some(Deref @ "x"),
type_annotation: TypeAnnotation::CommonName(CommonTypes::String, span!(12, 18)),
position: _,
},
_,
Expand Down Expand Up @@ -1227,7 +1231,11 @@ mod tests {
parts: Deref @ [
(
Deref @ "test-",
AnnotationWithBinder::NoAnnotation(TypeAnnotation::Name(TypeName::Name(Deref @ "X"), span!(8, 9)))
AnnotationWithBinder {
type_annotation: TypeAnnotation::Name(TypeName::Name(Deref @ "X"), span!(8, 9)),
name: None,
position: _
}
)
],
..
Expand Down
2 changes: 1 addition & 1 deletion parser/src/variable_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl ASTNode for VariableField {
Self::Object { members, spread, position: _, .. } => {
#[cfg(feature = "extras")]
if let Self::Object { class_name: Some(class_name), .. } = self {
buf.push_str(&class_name);
buf.push_str(class_name);
options.push_gap_optionally(buf);
}

Expand Down

0 comments on commit 0d65135

Please sign in to comment.