Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
PUP 4.3.1
-
None
-
None
-
2
-
Language 2016-01-13, Language 2016-01-27, Language 2016-02-10
-
New Feature
-
Description
Commit 3a9db247c432d469e625d4abf7bee8e747178af9 regressed support for "descending" ranges, where the "max" is less than the "min":
notice Integer[5, 1]
|
Integer[5, 1].each |$x| {
|
notice $x
|
}
|
This is expected to output:
Notice: Scope(Class[main]): Integer[5, 1]
|
Notice: Scope(Class[main]): 5
|
Notice: Scope(Class[main]): 4
|
Notice: Scope(Class[main]): 3
|
Notice: Scope(Class[main]): 2
|
Notice: Scope(Class[main]): 1
|
This is because having a maximum less than a minimum treats the range as being in "descending" order.
Instead, this is the actual output:
Notice: Scope(Class[main]): Integer[1, 5]
|
Notice: Scope(Class[main]): 1
|
Notice: Scope(Class[main]): 2
|
Notice: Scope(Class[main]): 3
|
Notice: Scope(Class[main]): 4
|
Notice: Scope(Class[main]): 5
|
It appears the min and max are silently being swapped when the max < min.
Related: I believe the compiler should error if a type is given a max argument less than a min argument when the type does not support a "descending" semantic, e.g. Callable[1, 0] should error rather than silently swapping the min and max.
Attachments
Issue Links
- blocks
-
PUP-5729 Add a reverse_each function
-
- Closed
-
-
PUP-5771 Add introduction to Iterable and Iterator to Pre-docs for PUP-5648
-
- Resolved
-
-
PUP-5772 Update lang specification with new types Iterable and Iterator
-
- Resolved
-
- relates to
-
PUP-5658 Disallow numeric ranges where from > to
-
- Closed
-
-
PUP-4702 Replace rgen model for the Puppet Type system with immutable classes
-
- Closed
-
-
DOCUMENT-1293 Iterable behavior of Integers not documented?
-
- Accepted
-
- supports
-
PUP-5773 Performance Work in Puppet
-
- Closed
-
- links to