diff --git a/lint/deprecated_key_functions_analyzer.go b/lint/deprecated_key_functions_analyzer.go index 8706967a..4ee1fd43 100644 --- a/lint/deprecated_key_functions_analyzer.go +++ b/lint/deprecated_key_functions_analyzer.go @@ -57,7 +57,7 @@ var DeprecatedKeyFunctionsAnalyzer = (func() *analysis.Analyzer { return } - memberInfo := elaboration.MemberExpressionMemberInfos[memberExpression] + memberInfo, _ := elaboration.MemberExpressionMemberInfo(memberExpression) member := memberInfo.Member if member == nil { return @@ -70,9 +70,9 @@ var DeprecatedKeyFunctionsAnalyzer = (func() *analysis.Analyzer { var replacement string functionName := member.Identifier.Identifier switch functionName { - case sema.AuthAccountAddPublicKeyField: + case sema.AuthAccountTypeAddPublicKeyFunctionName: replacement = "keys.add" - case sema.AuthAccountRemovePublicKeyField: + case sema.AuthAccountTypeRemovePublicKeyFunctionName: replacement = "keys.revoke" default: return diff --git a/lint/number_function_argument_analyzer.go b/lint/number_function_argument_analyzer.go index eee90be6..2f7fa6d1 100644 --- a/lint/number_function_argument_analyzer.go +++ b/lint/number_function_argument_analyzer.go @@ -184,17 +184,29 @@ var NumberFunctionArgumentAnalyzer = (func() *analysis.Analyzer { switch expr := element.(type) { case *ast.IntegerExpression: - argumentData, ok := elaboration.NumberConversionArgumentTypes[expr] - if !ok { + argumentData := elaboration.NumberConversionArgumentTypes(expr) + if argumentData.Type == nil { return } - diagnostic = suggestIntegerLiteralConversionReplacement(expr, location, argumentData.Type, argumentData.Range) + diagnostic = suggestIntegerLiteralConversionReplacement( + expr, + location, + argumentData.Type, + argumentData.Range, + ) + case *ast.FixedPointExpression: - argumentData, ok := elaboration.NumberConversionArgumentTypes[expr] - if !ok { + argumentData := elaboration.NumberConversionArgumentTypes(expr) + if argumentData.Type == nil { return } - diagnostic = suggestFixedPointLiteralConversionReplacement(expr, location, argumentData.Type, argumentData.Range) + diagnostic = suggestFixedPointLiteralConversionReplacement( + expr, + location, + argumentData.Type, + argumentData.Range, + ) + default: return } diff --git a/lint/redundant_cast_analyzer.go b/lint/redundant_cast_analyzer.go index 38d08905..0c1ae5eb 100644 --- a/lint/redundant_cast_analyzer.go +++ b/lint/redundant_cast_analyzer.go @@ -261,8 +261,9 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer { return } - redundantType, ok := elaboration.StaticCastTypes[castingExpression] - if ok && isRedundantCast(castingExpression.Expression, + redundantType := elaboration.StaticCastTypes(castingExpression) + if redundantType.ExprActualType != nil && isRedundantCast( + castingExpression.Expression, redundantType.ExprActualType, redundantType.TargetType, redundantType.ExpectedType, @@ -278,8 +279,10 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer { return } - alwaysSucceedingTypes, ok := elaboration.RuntimeCastTypes[castingExpression] - if ok && sema.IsSubType(alwaysSucceedingTypes.Left, alwaysSucceedingTypes.Right) { + alwaysSucceedingTypes := elaboration.RuntimeCastTypes(castingExpression) + if alwaysSucceedingTypes.Left != nil && + sema.IsSubType(alwaysSucceedingTypes.Left, alwaysSucceedingTypes.Right) { + switch castingExpression.Operation { case ast.OperationFailableCast: report( @@ -293,6 +296,7 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer { alwaysSucceedingTypes.Right), }, ) + case ast.OperationForceCast: report( analysis.Diagnostic{ @@ -305,6 +309,7 @@ var RedundantCastAnalyzer = (func() *analysis.Analyzer { alwaysSucceedingTypes.Right), }, ) + default: panic(errors.NewUnreachableError()) } diff --git a/lint/unnecessary_force_analyzer.go b/lint/unnecessary_force_analyzer.go index 106d401e..291ce050 100644 --- a/lint/unnecessary_force_analyzer.go +++ b/lint/unnecessary_force_analyzer.go @@ -50,8 +50,8 @@ var UnnecessaryForceAnalyzer = (func() *analysis.Analyzer { if !ok { return } - valueType := elaboration.ForceExpressionTypes[forceExpression] + valueType := elaboration.ForceExpressionType(forceExpression) if valueType == nil { return }