// Copyright 2026 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package contraire defines a tool (of the same name) which is a // syntax-directed fuzzer for randomly generating Go programs with the goal of // tripping up the type checkers. package contraire /* Programs generated by Contraire adhere to the below grammar: Prog = ConstDecl+ TypeDecl+ MethodDecl* // Declarations ConstDecl = "const" constName "=" ConstExpr TypeDecl = "type" typeDeclName [ "[" TypeParamDecl+ "]" ] [ "=" ] TypeExpr TypeParamDecl = typeParamName TypeExpr MethodDecl = "func" "(" [ "*" ] typeDeclName [ "[" typeParamName+ "]" ] ")" methodName [ "[" TypeParamDecl+ "]" ] "(" TypeExpr* ")" [ "(" TypeExpr+ ")" ] "{" "panic(1)" "}" // Constant Expressions ConstExpr = constName | constLtrl | ConstUnsafeSizeof constLtrl = "1" ConstUnsafeSizeof = "unsafe.Sizeof(*new(" TypeExpr "))" // Type Expressions TypeExpr = TypeName | TypeLtrl TypeName = typeParamName | typeDeclName [ "[" TypeExpr+ "]" ] TypeLtrl = typeAny | TypeMap | typeBasic | TypeArray | TypeSlice | TypeStruct | TypePointer | TypeFunction | TypeInterface typeAny = "any" TypeMap = "map" "[" TypeExpr "]" TypeExpr typeBasic = "int" TypeArray = "[" ConstExpr "]" TypeExpr TypeSlice = "[" "]" TypeExpr TypeStruct = "struct" "{" ( [ "*" ] TypeName | fieldName TypeExpr )* "}" TypePointer = "*" TypeExpr TypeFunction = "func" "(" TypeExpr* ")" [ "(" TypeExpr+ ")" ] TypeInterface = "interface" "{" ( methodName "(" TypeExpr* ")" [ "(" TypeExpr+ ")" ] )* "}" constName = (* a name defined by a constant declaration *) typeDeclName = (* a name defined by a type declaration *) typeParamName = (* a name defined by a type parameter declaration *) methodName = (* a name defined by a method declaration *) fieldName = (* a name defined by a field declaration *) */