Skip to content

NCCS: Helper.GetPatternType() not supported ByteString and BigInteger #992

@chenzhitong

Description

@chenzhitong

public static StackItemType GetPatternType(this ITypeSymbol type)
{
return type.ToString() switch
{
"bool" => StackItemType.Boolean,
"byte[]" => StackItemType.Buffer,
"string" => StackItemType.ByteString,
"Neo.SmartContract.Framework.ByteString" => StackItemType.ByteString,
"System.Numerics.BigInteger" => StackItemType.Integer,
_ => throw new CompilationException(type, DiagnosticId.SyntaxNotSupported, $"Unsupported pattern type: {type}")
};
}

The code above, looks like it supports ByteString and BigInteger, but in fact, if it's written this way in the contract, he'll report an error somewhere else.

public void M(object o1)
{
    switch (o1)
    {
        case byte[]: break;       // Compile Successfully
        case string: break;       // Compile Successfully
        case bool: break;         // Compile Successfully
        case ByteString: break;   //Compile Failure
        case BigInteger: break;   //Compile Failure
    }
}
image This method(ConvertIdentifierNameExpression) throws an exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions