1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#[derive(Copy, Clone)]
pub enum ReportCode {
    AssertWrongType,
    ParseFail,
    CompilerVersionError,
    WrongTypesInAssignOperation,
    WrongNumberOfArguments(usize, usize),
    UndefinedFunction,
    UndefinedTemplate,
    UninitializedSymbolInExpression,
    UnableToTypeFunction,
    UnreachableConstraints,
    UnknownIndex,
    UnknownDimension,
    SameFunctionDeclaredTwice,
    SameTemplateDeclaredTwice,
    SameSymbolDeclaredTwice,
    StaticInfoWasOverwritten,
    SignalInLineInitialization,
    SignalOutsideOriginalScope,
    FunctionWrongNumberOfArguments,
    FunctionInconsistentTyping,
    FunctionPathWithoutReturn,
    FunctionReturnError,
    ForbiddenDeclarationInFunction,
    NonHomogeneousArray,
    NonBooleanCondition,
    NonCompatibleBranchTypes,
    NonEqualTypesInExpression,
    NonExistentSymbol,
    NoMainFoundInProject,
    NoCompilerVersionWarning,
    MultipleMainInComponent,
    TemplateCallAsArgument,
    TemplateWrongNumberOfArguments,
    TemplateWithReturnStatement,
    TypeCantBeUseAsCondition,
    EmptyArrayInlineDeclaration,
    PrefixOperatorWithWrongTypes,
    InfixOperatorWithWrongTypes,
    InvalidArgumentInCall,
    InconsistentReturnTypesInBlock,
    InconsistentStaticInformation,
    InvalidArrayAccess,
    InvalidSignalAccess,
    InvalidArraySize,
    InvalidArrayType,
    ForStatementIllConstructed,
    BadArrayAccess,
    AssigningAComponentTwice,
    AssigningASignalTwice,
    NotAllowedOperation,
    ConstraintGeneratorInFunction,
    WrongSignalTags,
    InvalidPartialArray,
    MustBeSingleArithmetic,
    ExpectedDimDiffGotDim(usize, usize),
    RuntimeError,
    UnknownTemplate,
    NonQuadratic,
    NonConstantArrayLength,
    NonComputableExpression,
    // Constraint analysis codes
    UnconstrainedSignal,
    OneConstraintIntermediate,
    NoOutputInInstance,
    ErrorWat2Wasm,
    // Circomspect specific codes
    ShadowingVariable,
    ParameterNameCollision,
    FieldElementComparison,
    FieldElementArithmetic,
    SignalAssignmentStatement,
    UnecessarySignalAssignment,
    UnusedVariableValue,
    UnusedParameterValue,
    VariableWithoutSideEffect,
    ConstantBranchCondition,
    NonStrictBinaryConversion,
    CyclomaticComplexity,
    TooManyArguments,
}

impl ReportCode {
    pub fn id(&self) -> String {
        use self::ReportCode::*;
        match self {
            ParseFail => "P1000",
            NoMainFoundInProject => "P1001",
            MultipleMainInComponent => "P1002",
            CompilerVersionError => "P1003",
            NoCompilerVersionWarning => "P1004",
            WrongTypesInAssignOperation => "T2000",
            UndefinedFunction => "T2001",
            UndefinedTemplate => "T2002",
            UninitializedSymbolInExpression => "T2003",
            UnableToTypeFunction => "T2004",
            UnreachableConstraints => "T2005",
            SameFunctionDeclaredTwice => "T2006",
            SameTemplateDeclaredTwice => "T2007",
            SameSymbolDeclaredTwice => "T2008",
            StaticInfoWasOverwritten => "T2009",
            SignalInLineInitialization => "T2010",
            SignalOutsideOriginalScope => "T2011",
            FunctionWrongNumberOfArguments => "T2012",
            FunctionInconsistentTyping => "T2013",
            FunctionPathWithoutReturn => "T2014",
            FunctionReturnError => "T2015",
            ForbiddenDeclarationInFunction => "T2016",
            NonHomogeneousArray => "T2017",
            NonBooleanCondition => "T2018",
            NonCompatibleBranchTypes => "T2019",
            NonEqualTypesInExpression => "T2020",
            NonExistentSymbol => "T2021",
            TemplateCallAsArgument => "T2022",
            TemplateWrongNumberOfArguments => "T2023",
            TemplateWithReturnStatement => "T2024",
            TypeCantBeUseAsCondition => "T2025",
            EmptyArrayInlineDeclaration => "T2026",
            PrefixOperatorWithWrongTypes => "T2027",
            InfixOperatorWithWrongTypes => "T2028",
            InvalidArgumentInCall => "T2029",
            InconsistentReturnTypesInBlock => "T2030",
            InconsistentStaticInformation => "T2031",
            InvalidArrayAccess => "T2032",
            InvalidSignalAccess => "T2046",
            InvalidArraySize => "T2033",
            InvalidArrayType => "T2034",
            ForStatementIllConstructed => "T2035",
            BadArrayAccess => "T2035",
            AssigningAComponentTwice => "T2036",
            AssigningASignalTwice => "T2037",
            NotAllowedOperation => "T2038",
            ConstraintGeneratorInFunction => "T2039",
            WrongSignalTags => "T2040",
            AssertWrongType => "T2041",
            UnknownIndex => "T2042",
            InvalidPartialArray => "T2043",
            MustBeSingleArithmetic => "T2044",
            ExpectedDimDiffGotDim(..) => "T2045",
            RuntimeError => "T3001",
            UnknownDimension => "T20460",
            UnknownTemplate => "T20461",
            NonQuadratic => "T20462",
            NonConstantArrayLength => "T20463",
            NonComputableExpression => "T20464",
            WrongNumberOfArguments(..) => "T20465",
            // Constraint analysis codes
            UnconstrainedSignal => "CA01",
            OneConstraintIntermediate => "CA02",
            NoOutputInInstance => "CA03",
            ErrorWat2Wasm => "W01",
            // Circomspect specific codes
            ShadowingVariable => "CS0001",
            ParameterNameCollision => "CS0002",
            FieldElementComparison => "CS0003",
            FieldElementArithmetic => "CS0004",
            SignalAssignmentStatement => "CS0005",
            UnusedVariableValue => "CS0006",
            UnusedParameterValue => "CS0007",
            VariableWithoutSideEffect => "CS0008",
            ConstantBranchCondition => "CS0009",
            NonStrictBinaryConversion => "CS0010",
            CyclomaticComplexity => "CS0011",
            TooManyArguments => "CS0012",
            UnecessarySignalAssignment => "CS0013",
        }
        .to_string()
    }
}