Module LustreTypeChecker

Functions for type checking surface syntax LustreAst

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

Resolve a match pattern against the type it matches, returning the context the arm's body is checked in and the pattern with each nullary-constructor variable pattern resolved to a constructor pattern

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

Check if two lustre types are equal

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