Skip to content

Commit e32f9fe

Browse files
authored
fix: move std types into std.types module, disambiguate text and date types (#6155)
1 parent 22efc1a commit e32f9fe

6 files changed

Lines changed: 34 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
**Language**:
66

7+
- Move all standard types into a dedicated `std.types` submodule in order to
8+
disambiguate between `type text` - `module text` and `type date` -
9+
`module date`. (@kgutwin, #6155)
10+
711
**Features**:
812

913
- Add simple enumeration type, and dedicated support for name resolution when an

prqlc/prqlc/src/semantic/module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl Module {
3535
Ident::from_name(NS_THIS),
3636
Ident::from_name(NS_THAT),
3737
Ident::from_name(NS_PARAM),
38+
Ident::from_path(vec![NS_STD, "types"]),
3839
Ident::from_name(NS_STD),
3940
],
4041
}

prqlc/prqlc/src/semantic/resolver/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl super::Resolver<'_> {
170170

171171
if def.name == "main" {
172172
def.ty = Some(Ty::new(TyKind::Ident(Ident::from_path(vec![
173-
"std", "relation",
173+
"std", "types", "relation",
174174
]))));
175175
}
176176

prqlc/prqlc/src/semantic/std.prql

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,29 @@ let not = expr<bool> -> <bool> internal std.not
3737

3838
# Types
3939

40-
## Type primitives
41-
type int = int
42-
type float = float
43-
type bool = bool
44-
type text = text
45-
type date = date
46-
type time = time
47-
type timestamp = timestamp
48-
type `func` = func
49-
50-
## Generic array
51-
type array = []
52-
53-
## Generic relation
54-
type relation = [{..}]
55-
56-
## Range
57-
type range = {start = *, end = *}
58-
59-
## Transform
60-
type transform = func relation -> relation
40+
module types {
41+
## Type primitives
42+
type int = int
43+
type float = float
44+
type bool = bool
45+
type text = text
46+
type date = date
47+
type time = time
48+
type timestamp = timestamp
49+
type `func` = func
50+
51+
## Generic array
52+
type array = []
53+
54+
## Generic relation
55+
type relation = [{..}]
56+
57+
## Range
58+
type range = {start = *, end = *}
59+
60+
## Transform
61+
type transform = func relation -> relation
62+
}
6163

6264
# Functions
6365

prqlc/prqlc/tests/integration/error_messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn test_ambiguous() {
195195
│ ──┬─
196196
│ ╰─── Ambiguous name
197197
198-
│ Help: could be any of: std.date, this.date
198+
│ Help: could be any of: std.date, std.types.date, this.date
199199
200200
│ Note: available columns: date
201201
───╯

prqlc/prqlc/tests/integration/snapshots/integration__queries__debug_lineage__set_ops_remove.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ nodes:
184184
span: [std]
185185
children:
186186
- 59
187-
- 4000000155
187+
- 4000000156
188188
parent: 69
189189
- id: 67
190190
kind: Ident
@@ -224,14 +224,14 @@ nodes:
224224
children:
225225
- 69
226226
- 70
227-
- id: 4000000155
227+
- id: 4000000156
228228
kind: RqOperator
229229
span: [std]
230230
targets:
231231
- 62
232-
- 4000000157
232+
- 4000000158
233233
parent: 66
234-
- id: 4000000157
234+
- id: 4000000158
235235
kind: Literal
236236
span: [std]
237237
ast:

0 commit comments

Comments
 (0)