compiler-core
test-package-compiler
cases
erlang_import_shadowing_prelude
src
···
186
186
// );
187
187
188
188
assert_erlang_compile!(
189
189
-
vec![Source {
190
190
-
origin: Origin::Src,
191
191
-
path: PathBuf::from("/src/one/two.gleam"),
192
192
-
name: "one/two".to_string(),
193
193
-
code: "pub type Box { Box }".to_string(),
194
194
-
}],
195
195
-
Ok(vec![OutputFile {
196
196
-
path: PathBuf::from("_build/default/lib/the_package/_gleam_artefacts/one@two.erl"),
197
197
-
content: Content::Text(
198
198
-
"-module(one@two).
199
199
-
-compile(no_auto_import).
200
200
-
201
201
-
-export_type([box/0]).
202
202
-
203
203
-
-type box() :: box.
204
204
-
205
205
-
206
206
-
"
207
207
-
.to_string()
208
208
-
),
209
209
-
}]),
210
210
-
);
211
211
-
212
212
-
assert_erlang_compile!(
213
189
vec![
214
190
Source {
215
191
origin: Origin::Src,
···
2112
2088
]),
2113
2089
);
2114
2090
}
2115
2115
-
2116
2116
-
// https://github.com/gleam-lang/gleam/issues/1495
2117
2117
-
#[test]
2118
2118
-
fn import_error() {
2119
2119
-
assert_erlang_compile!(
2120
2120
-
vec![
2121
2121
-
Source {
2122
2122
-
origin: Origin::Src,
2123
2123
-
path: PathBuf::from("/src/one.gleam"),
2124
2124
-
name: "one".to_string(),
2125
2125
-
code: "pub type Error { MyError }".to_string(),
2126
2126
-
},
2127
2127
-
Source {
2128
2128
-
origin: Origin::Src,
2129
2129
-
path: PathBuf::from("/src/two.gleam"),
2130
2130
-
name: "two".to_string(),
2131
2131
-
code: r#"import one.{Error}"#.to_string(),
2132
2132
-
},
2133
2133
-
],
2134
2134
-
Ok(vec![
2135
2135
-
OutputFile {
2136
2136
-
path: PathBuf::from("_build/default/lib/the_package/_gleam_artefacts/one.erl"),
2137
2137
-
content: Content::Text(
2138
2138
-
"-module(one).
2139
2139
-
-compile(no_auto_import).
2140
2140
-
2141
2141
-
-export_type([error/0]).
2142
2142
-
2143
2143
-
-type error() :: my_error.
2144
2144
-
2145
2145
-
2146
2146
-
"
2147
2147
-
.to_string()
2148
2148
-
),
2149
2149
-
},
2150
2150
-
OutputFile {
2151
2151
-
path: PathBuf::from("_build/default/lib/the_package/_gleam_artefacts/two.erl"),
2152
2152
-
content: Content::Text("-module(two).\n".to_string()),
2153
2153
-
}
2154
2154
-
]),
2155
2155
-
);
2156
2156
-
}
···
1
1
+
# https://github.com/gleam-lang/gleam/issues/1495
2
2
+
name = "importy"
3
3
+
version = "0.1.0"
4
4
+
target = "erlang"
···
1
1
+
pub type Error {
2
2
+
// This constructor shadows the Error constructor in the prelude.
3
3
+
Error
4
4
+
}
···
1
1
+
// This import shadows the Error type in the prelude.
2
2
+
import one.{Error}
3
3
+
4
4
+
pub fn main() {
5
5
+
Error
6
6
+
}
···
1
1
+
---
2
2
+
source: test-package-compiler/src/generated_tests.rs
3
3
+
assertion_line: 37
4
4
+
expression: /Users/louis/src/gleam/gleam/test-package-compiler/cases/erlang_import_shadowing_prelude
5
5
+
---
6
6
+
//// /out/lib/the_package/_gleam_artefacts/one.erl
7
7
+
-module(one).
8
8
+
-compile(no_auto_import).
9
9
+
10
10
+
-export_type([error/0]).
11
11
+
12
12
+
-type error() :: error.
13
13
+
14
14
+
15
15
+
16
16
+
17
17
+
//// /out/lib/the_package/_gleam_artefacts/two.erl
18
18
+
-module(two).
19
19
+
-compile(no_auto_import).
20
20
+
21
21
+
-export([main/0]).
22
22
+
23
23
+
-spec main() -> one:error().
24
24
+
main() ->
25
25
+
error.
26
26
+
27
27
+
28
28
+
//// /out/lib/the_package/ebin/importy.app
29
29
+
{application, importy, [
30
30
+
{vsn, "0.1.0"},
31
31
+
{applications, []},
32
32
+
{description, ""},
33
33
+
{modules, [one,
34
34
+
two]},
35
35
+
{registered, []}
36
36
+
]}.
37
37
+
38
38
+
39
39
+