diff --git a/src/reference-manual/expressions.Rmd b/src/reference-manual/expressions.Rmd index 691d37704..501c263d5 100644 --- a/src/reference-manual/expressions.Rmd +++ b/src/reference-manual/expressions.Rmd @@ -613,10 +613,10 @@ a ? b : c ``` is an expression of the promoted type of `b` and `c`. The -only promotion allowed in Stan is from integer to real; if one +only promotion allowed in Stan is integer -> real -> complex; e.g. if one argument is of type `int` and the other of type `real`, the -conditional expression as a whole is of type `real`. In all -other cases, the arguments have to be of the same underlying Stan type +conditional expression as a whole is of type `real`. +In other cases, the arguments have to be of the same underlying Stan type (i.e., constraints don't count, only the shape) and the conditional expression is of that type. @@ -1070,7 +1070,7 @@ to complex expressions. ### Promotion -There are two promotion rules. First, integer expressions of type +There are three promotion rules. First, integer expressions of type `int` may be used anywhere an expression of type `real` is used. An integer is promoted to real by casting it in the underlying C++. @@ -1083,7 +1083,9 @@ Promotion is transitive, so that integers may be promoted to complex numbers in two stages, first converting the integer to real, then converting the real value to a complex type. - +The third rule is (starting with Stan 2.29), array types are promoted +according to their contained type. For example, `array[,] int` may be +used where `array [,] real` or `array [,] complex` is required. #### Literals {-} diff --git a/src/reference-manual/syntax.Rmd b/src/reference-manual/syntax.Rmd index 9517b1d25..eecaf43aa 100644 --- a/src/reference-manual/syntax.Rmd +++ b/src/reference-manual/syntax.Rmd @@ -375,8 +375,9 @@ quantities blocks. The types of expressions used for elements in array expressions (`'{' expressions '}'`) must all be of the same type or a mixture -of `int` and `real` types (in which case the result is -promoted to be of type `real`). +of scalar (`int`, `real` and `complex`) types (in which case the result +is promoted to be of the highest type on the `int -> real -> complex` +hierarchy). ### Forms of numbers {-}