File tree Expand file tree Collapse file tree 2 files changed +62
-3
lines changed
crates/compiler/load_internal Expand file tree Collapse file tree 2 files changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -1317,8 +1317,13 @@ fn handle_root_type<'a>(
1317
1317
1318
1318
use HeaderType :: * ;
1319
1319
1320
+ let use_main = match header_type {
1321
+ Package { .. } | App { .. } | Platform { .. } => true ,
1322
+ Module { .. } | Builtin { .. } | Hosted { .. } => false ,
1323
+ } ;
1324
+
1320
1325
match header_type {
1321
- Module { .. } | Builtin { .. } | Hosted { .. } => {
1326
+ Module { .. } | Builtin { .. } | Hosted { .. } | Package { .. } => {
1322
1327
let main_path = opt_main_path. or_else ( || find_main_roc_recursively ( src_dir) ) ;
1323
1328
1324
1329
let cache_dir = roc_cache_dir. as_persistent_path ( ) ;
@@ -1340,9 +1345,15 @@ fn handle_root_type<'a>(
1340
1345
header_output. msg = Msg :: Many ( messages) ;
1341
1346
}
1342
1347
1343
- Ok ( ( header_output, RootType :: Module { main_path } ) )
1348
+ let root_type = if use_main {
1349
+ RootType :: Main
1350
+ } else {
1351
+ RootType :: Module { main_path }
1352
+ } ;
1353
+
1354
+ Ok ( ( header_output, root_type) )
1344
1355
}
1345
- App { .. } | Package { .. } | Platform { .. } => Ok ( ( header_output, RootType :: Main ) ) ,
1356
+ App { .. } | Platform { .. } => Ok ( ( header_output, RootType :: Main ) ) ,
1346
1357
}
1347
1358
} else {
1348
1359
Ok ( ( header_output, RootType :: Main ) )
Original file line number Diff line number Diff line change @@ -2131,3 +2131,51 @@ fn roc_file_no_extension() {
2131
2131
2132
2132
assert_eq ! ( err, expected, "\n {}" , err) ;
2133
2133
}
2134
+
2135
+ #[ test]
2136
+ fn roc_package_depends_on_other_package ( ) {
2137
+ let modules = vec ! [
2138
+ (
2139
+ "main" ,
2140
+ indoc!(
2141
+ r#"
2142
+ package [Module] { other: "other/main.roc" }
2143
+ "#
2144
+ ) ,
2145
+ ) ,
2146
+ (
2147
+ "Module.roc" ,
2148
+ indoc!(
2149
+ r#"
2150
+ module [foo]
2151
+
2152
+ import other.OtherMod
2153
+
2154
+ foo = OtherMod.say "hello"
2155
+ "#
2156
+ ) ,
2157
+ ) ,
2158
+ (
2159
+ "other/main.roc" ,
2160
+ indoc!(
2161
+ r#"
2162
+ package [OtherMod] {}
2163
+ "#
2164
+ ) ,
2165
+ ) ,
2166
+ (
2167
+ "other/OtherMod.roc" ,
2168
+ indoc!(
2169
+ r#"
2170
+ module [say]
2171
+
2172
+ say = \msg -> "$(msg), world!"
2173
+ "#
2174
+ ) ,
2175
+ ) ,
2176
+ ] ;
2177
+
2178
+ let result = multiple_modules ( "roc_package_depends_on_other_package" , modules) ;
2179
+
2180
+ assert ! ( result. is_ok( ) ) ;
2181
+ }
You can’t perform that action at this time.
0 commit comments