Skip to content

Commit

Permalink
chore: fix csharpier
Browse files Browse the repository at this point in the history
  • Loading branch information
kthompson committed May 31, 2024
1 parent 2363d1e commit 1a8b16f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- uses: actions/checkout@v2
- run: |
dotnet tool restore
dotnet csharpier --check
dotnet csharpier --check .
1 change: 0 additions & 1 deletion src/Panther/CodeAnalysis/Symbols/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 14 additions & 4 deletions src/Panther/CodeAnalysis/Typing/TypedBinaryOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
3 changes: 1 addition & 2 deletions src/Panther/CodeAnalysis/Typing/TypedLabelStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/Panther/CodeAnalysis/Typing/TypedNodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Typing/Typer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 1a8b16f

Please sign in to comment.