Module LustreTypeChecker

Functions for type checking surface syntax LustreAst

module LA = LustreAst
type error_kind =
  1. | Unknown of string
  2. | Impossible of string
  3. | MergeCaseExtraneous of HString.t * TypeCheckerContext.tc_type
  4. | MergeCaseMissing of HString.t
  5. | MergeCaseNotUnique of HString.t
  6. | UnboundIdentifier of HString.t
  7. | UnboundModeReference of HString.t
  8. | UnboundNodeName of HString.t
  9. | NotAFieldOfRecord of HString.t
  10. | AssumptionOnCurrentOutput of HString.t
  11. | NoValueForRecordField of HString.t
  12. | IlltypedFieldProjection of TypeCheckerContext.tc_type
  13. | TupleIndexOutOfBounds of int * TypeCheckerContext.tc_type
  14. | IlltypedTupleProjection of TypeCheckerContext.tc_type
  15. | NonConcreteTupleProjection of TypeCheckerContext.LA.expr
  16. | UnequalIteBranchTypes of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  17. | ExpectedBooleanExpression of TypeCheckerContext.tc_type
  18. | ExpectedIntegerExpression of TypeCheckerContext.tc_type
  19. | Unsupported of string
  20. | UnequalArrayExpressionType
  21. | TypeMismatchOfRecordLabel of HString.t * TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  22. | IlltypedUpdateWithLabel of TypeCheckerContext.tc_type
  23. | IlltypedUpdateWithIndex of TypeCheckerContext.tc_type
  24. | IlltypedUpdate of TypeCheckerContext.tc_type
  25. | ExpectedLabel of TypeCheckerContext.LA.expr
  26. | ExpectedIntegerLiteral of TypeCheckerContext.LA.expr
  27. | IlltypedArraySlice of TypeCheckerContext.tc_type
  28. | ExpectedIntegerTypeForSlice
  29. | IlltypedIndexAccess of TypeCheckerContext.tc_type
  30. | IlltypedMapIndex of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  31. | ExpectedIntegerTypeForArrayIndex of TypeCheckerContext.tc_type
  32. | IlltypedArrayConcat of bool * TypeCheckerContext.tc_type * TypeCheckerContext.tc_type option
  33. | IlltypedDefaults
  34. | IlltypedMerge of TypeCheckerContext.tc_type
  35. | IlltypedFby of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  36. | IlltypedArrow of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  37. | IlltypedCall of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  38. | IlltypedRecord of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  39. | ExpectedFunctionType of TypeCheckerContext.tc_type
  40. | IlltypedIdentifier of HString.t * TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  41. | UnificationFailed of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  42. | ExpectedType of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  43. | EmptyArrayExpression
  44. | ExpectedArrayType of TypeCheckerContext.tc_type
  45. | MismatchedNodeType of HString.t * TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  46. | IlltypedBitNot of TypeCheckerContext.tc_type
  47. | IlltypedUnaryMinus of TypeCheckerContext.tc_type
  48. | ExpectedIntegerTypes of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  49. | ExpectedNumberOrSetTypes of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  50. | ExpectedMachineIntegerTypes of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  51. | ExpectedUnsignedMachineIntegerTypes of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  52. | ExpectedMachineIntegerType of TypeCheckerContext.tc_type
  53. | ExpectedBitShiftConstantOfSameWidth of TypeCheckerContext.tc_type
  54. | ExpectedBitShiftMachineIntegerType of TypeCheckerContext.tc_type
  55. | InvalidConversion of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  56. | NodeArgumentOnLHS of HString.t
  57. | MismatchOfEquationType of TypeCheckerContext.LA.struct_item list option * TypeCheckerContext.tc_type
  58. | DisallowedReassignment of TypeCheckerContext.ty_set
  59. | AssumptionMustBeInputOrOutput of HString.t
  60. | Redeclaration of HString.t
  61. | ExpectedConstant of string * string
  62. | UndeclaredType of HString.t
  63. | EmptySubrange of int * int
  64. | SubrangeArgumentMustBeConstantInteger of TypeCheckerContext.LA.expr
  65. | IntervalMustHaveBound
  66. | ExpectedRecordType of TypeCheckerContext.tc_type
  67. | UnsupportedQuantifiedVariable of HString.t
  68. | InvalidPolymorphicCall of HString.t
  69. | InvalidNumberOfIndices of HString.t
  70. | InvalidExtractUpperBound of int * int
  71. | InvalidExtractLowerBound of int * int
  72. | UnsupportedMapType of TypeCheckerContext.tc_type
  73. | ExpectedMapSetType of TypeCheckerContext.tc_type
  74. | ClockMismatchInMerge
  75. | IllegalClockExprInActivate of LustreAst.expr
  76. | CallRequiresExplicitAnnotation of HString.t
  77. | TempOperatorInFuncInterface of NodeId.t
  78. | TempOperatorInFuncTypeAscription
  79. | NoIndexAccessInArrayLength of TypeCheckerContext.tc_type
  80. | NestedTypeTemporal of LustreAst.lustre_type
  81. | NestedTypeNodeCall of LustreAst.lustre_type
  82. | UnboundConstructor of HString.t
  83. | ConstructorArityMismatch of HString.t * int * int
  84. | MatchScrutineeNotADT of TypeCheckerContext.tc_type
  85. | UnequalMatchArmTypes of TypeCheckerContext.tc_type * TypeCheckerContext.tc_type
  86. | DuplicateConstructor of HString.t * HString.t * HString.t
  87. | ConstructorNameClashWithConst of HString.t * HString.t
  88. | NonWellFoundedDatatype of HString.t
  89. | InvalidDecreasesType of TypeCheckerContext.tc_type
  90. | ADTInLexicographicDecreases of TypeCheckerContext.tc_type
  91. | NonRecursiveADTDecreases of TypeCheckerContext.tc_type
  92. | NonInputInADTDecreasesMeasure of HString.t
  93. | UnsupportedRecursiveAdtField of HString.t * HString.t
  94. | RecursiveFieldWithTypeArgs of HString.t * HString.t
  95. | UnsupportedRefinementInRecursiveAdtField of HString.t * HString.t
  96. | DuplicateFieldName of HString.t * HString.t * HString.t
  97. | DuplicateFieldNameInCtor of HString.t * HString.t
  98. | NotAFieldOfADT of HString.t
type error = [
  1. | `LustreTypeCheckerError of Lib.position * error_kind
  2. | `LustreAstInlineConstantsError of Lib.position * LustreAstInlineConstants.error_kind
]
type warning_kind =
  1. | UnusedBoundVariableWarning of HString.t
type warning = [
  1. | `LustreTypeCheckerWarning of Lib.position * warning_kind
]
val warning_message : warning_kind -> string
val error_if_lus_strict : warning_kind -> bool
val error_message : error_kind -> string
val type_error : Lib.position -> error_kind -> ('a, [> error ]) Stdlib.result

type_error returns an Error of tc_result

val type_check_infer_globals : TypeCheckerContext.tc_context -> TypeCheckerContext.LA.t -> (TypeCheckerContext.LA.t * TypeCheckerContext.tc_context * [> warning ] list, [> error ]) Stdlib.result

Typechecks the toplevel globals i.e. constant decls and type decls. It returns a Ok (tc_context) if it succeeds or and Error of String if the typechecker fails

val type_check_infer_nodes_and_contracts : TypeCheckerContext.tc_context -> TypeCheckerContext.LA.t -> (TypeCheckerContext.tc_context * TypeCheckerContext.LA.t * [> warning ] list, [> error ]) Stdlib.result

Typechecks and infers type for the nodes and contracts. It returns a Ok (tc_context) if it succeeds or and Error of String if the typechecker fails

val expand_type_syn_reftype : ?expand_history:bool -> TypeCheckerContext.tc_context -> TypeCheckerContext.tc_type -> (TypeCheckerContext.tc_type, [> error ]) Stdlib.result
val expand_type_syn_reftype_history : TypeCheckerContext.tc_context -> TypeCheckerContext.tc_type -> (TypeCheckerContext.tc_type, [> error ]) Stdlib.result

Infer type of Lustre expression given a typing context

Convert the GenericIndex to one of the other indices based on type information

Check if two lustre types are equal

val tc_ctx_of_contract_node_decl : Lib.position -> TypeCheckerContext.tc_context -> TypeCheckerContext.LA.contract_node_decl -> (TypeCheckerContext.tc_context * [> warning ] list, [> error ]) Stdlib.result
val tc_ctx_of_node_decl : Lib.position -> TypeCheckerContext.tc_context -> TypeCheckerContext.LA.node_decl -> bool -> (TypeCheckerContext.tc_context * [> warning ] list, [> error ]) Stdlib.result
val expr_contains_set_binop : TypeCheckerContext.tc_context -> TypeCheckerContext.NI.t option -> TypeCheckerContext.LA.expr -> bool

`expr_contains_set_binop e` returns true iff `e` contains set equality, set union or set intersection