From 1a8b16fef76d47a65fd72c62f0ce3b883a5194d3 Mon Sep 17 00:00:00 2001 From: Kevin Thompson Date: Thu, 30 May 2024 19:41:14 -0700 Subject: [PATCH] chore: fix csharpier --- .github/workflows/lint.yaml | 2 +- src/Panther/CodeAnalysis/Symbols/Type.cs | 1 - .../CodeAnalysis/Typing/TypedBinaryOperator.cs | 18 ++++++++++++++---- .../CodeAnalysis/Typing/TypedLabelStatement.cs | 3 +-- src/Panther/CodeAnalysis/Typing/TypedNodes.cs | 1 - src/Panther/CodeAnalysis/Typing/Typer.cs | 3 ++- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index cc58912..e41bd6a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -10,4 +10,4 @@ jobs: - uses: actions/checkout@v2 - run: | dotnet tool restore - dotnet csharpier --check + dotnet csharpier --check . diff --git a/src/Panther/CodeAnalysis/Symbols/Type.cs b/src/Panther/CodeAnalysis/Symbols/Type.cs index 4a7c977..f6c4e14 100644 --- a/src/Panther/CodeAnalysis/Symbols/Type.cs +++ b/src/Panther/CodeAnalysis/Symbols/Type.cs @@ -9,7 +9,6 @@ public abstract record Type public bool IsValueType => this == Type.Bool || this == Type.Int || this == Type.Char; public bool IsReferenceType => !IsValueType; - protected Type(Symbol symbol) { Symbol = symbol; diff --git a/src/Panther/CodeAnalysis/Typing/TypedBinaryOperator.cs b/src/Panther/CodeAnalysis/Typing/TypedBinaryOperator.cs index 4edf0e1..9c2ac92 100644 --- a/src/Panther/CodeAnalysis/Typing/TypedBinaryOperator.cs +++ b/src/Panther/CodeAnalysis/Typing/TypedBinaryOperator.cs @@ -176,10 +176,20 @@ private TypedBinaryOperator(TypedBinaryOperatorKind kind, SyntaxKind syntaxKind, public static TypedBinaryOperator? Bind(SyntaxKind kind, Type leftType, Type rightType) => _operators.FirstOrDefault( - op => op.SyntaxKind == kind && ( - (op.LeftType == leftType || (op.LeftType.IsReferenceType && leftType == Type.Null)) && op.RightType == rightType || - (op.RightType == rightType || (op.RightType.IsReferenceType && rightType == Type.Null)) && op.LeftType == leftType - ) + op => + op.SyntaxKind == kind + && ( + ( + op.LeftType == leftType + || (op.LeftType.IsReferenceType && leftType == Type.Null) + ) + && op.RightType == rightType + || ( + op.RightType == rightType + || (op.RightType.IsReferenceType && rightType == Type.Null) + ) + && op.LeftType == leftType + ) ); public static TypedBinaryOperator BindOrThrow(SyntaxKind kind, Type leftType, Type rightType) => diff --git a/src/Panther/CodeAnalysis/Typing/TypedLabelStatement.cs b/src/Panther/CodeAnalysis/Typing/TypedLabelStatement.cs index a9a882a..9c3a2e8 100644 --- a/src/Panther/CodeAnalysis/Typing/TypedLabelStatement.cs +++ b/src/Panther/CodeAnalysis/Typing/TypedLabelStatement.cs @@ -2,8 +2,7 @@ namespace Panther.CodeAnalysis.Typing; -sealed record TypedLabelStatement(SyntaxNode Syntax, TypedLabel TypedLabel) - : TypedStatement(Syntax) +sealed record TypedLabelStatement(SyntaxNode Syntax, TypedLabel TypedLabel) : TypedStatement(Syntax) { public override TypedNodeKind Kind => TypedNodeKind.LabelStatement; diff --git a/src/Panther/CodeAnalysis/Typing/TypedNodes.cs b/src/Panther/CodeAnalysis/Typing/TypedNodes.cs index 3ca7e40..4e2c53c 100644 --- a/src/Panther/CodeAnalysis/Typing/TypedNodes.cs +++ b/src/Panther/CodeAnalysis/Typing/TypedNodes.cs @@ -92,7 +92,6 @@ internal partial record TypedVariableExpression public override Type Type { get; init; } = Variable.Type; } - internal partial record TypedNullExpression { public override Type Type { get; init; } = Type.Null; diff --git a/src/Panther/CodeAnalysis/Typing/Typer.cs b/src/Panther/CodeAnalysis/Typing/Typer.cs index 0f670dd..c77dbc6 100644 --- a/src/Panther/CodeAnalysis/Typing/Typer.cs +++ b/src/Panther/CodeAnalysis/Typing/Typer.cs @@ -951,7 +951,8 @@ ThisExpressionSyntax thisExpressionSyntax => BindThisExpression(thisExpressionSyntax, scope), NewExpressionSyntax newExpressionSyntax => BindNewExpression(newExpressionSyntax, scope), - NullExpressionSyntax nullExpressionSyntax => BindNullExpression(nullExpressionSyntax, scope), + NullExpressionSyntax nullExpressionSyntax + => BindNullExpression(nullExpressionSyntax, scope), UnaryExpressionSyntax unaryExpressionSyntax => BindUnaryExpression(unaryExpressionSyntax, scope), UnitExpressionSyntax unit => BindUnitExpression(unit),