mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
show platform header in error messages
This commit is contained in:
parent
c9f396b985
commit
dd8bdcb806
2 changed files with 48 additions and 20 deletions
|
@ -2332,6 +2332,10 @@ fn load_pkg_config<'a>(
|
|||
)))
|
||||
}
|
||||
Ok((ast::Module::Platform { header }, parser_state)) => {
|
||||
let delta = bytes.len() - parser_state.bytes.len();
|
||||
let chomped = &bytes[..delta];
|
||||
let header_src = unsafe { std::str::from_utf8_unchecked(chomped) };
|
||||
|
||||
// make a Pkg-Config module that ultimately exposes `main` to the host
|
||||
let pkg_config_module_msg = fabricate_pkg_config_module(
|
||||
arena,
|
||||
|
@ -2342,6 +2346,7 @@ fn load_pkg_config<'a>(
|
|||
module_ids.clone(),
|
||||
ident_ids_by_module.clone(),
|
||||
&header,
|
||||
header_src,
|
||||
pkg_module_timing,
|
||||
)
|
||||
.1;
|
||||
|
@ -2939,18 +2944,24 @@ fn send_header<'a>(
|
|||
)
|
||||
}
|
||||
|
||||
// TODO refactor so more logic is shared with `send_header`
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn send_header_two<'a>(
|
||||
arena: &'a Bump,
|
||||
#[derive(Debug)]
|
||||
struct PlatformHeaderInfo<'a> {
|
||||
filename: PathBuf,
|
||||
is_root_module: bool,
|
||||
shorthand: &'a str,
|
||||
header_src: &'a str,
|
||||
app_module_id: ModuleId,
|
||||
packages: &'a [Located<PackageEntry<'a>>],
|
||||
provides: &'a [Located<ExposesEntry<'a, &'a str>>],
|
||||
requires: &'a [Located<TypedIdent<'a>>],
|
||||
imports: &'a [Located<ImportsEntry<'a>>],
|
||||
}
|
||||
|
||||
// TODO refactor so more logic is shared with `send_header`
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn send_header_two<'a>(
|
||||
arena: &'a Bump,
|
||||
info: PlatformHeaderInfo<'a>,
|
||||
parse_state: parser::State<'a>,
|
||||
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||
ident_ids_by_module: Arc<Mutex<MutMap<ModuleId, IdentIds>>>,
|
||||
|
@ -2958,6 +2969,18 @@ fn send_header_two<'a>(
|
|||
) -> (ModuleId, Msg<'a>) {
|
||||
use inlinable_string::InlinableString;
|
||||
|
||||
let PlatformHeaderInfo {
|
||||
filename,
|
||||
shorthand,
|
||||
is_root_module,
|
||||
header_src,
|
||||
app_module_id,
|
||||
packages,
|
||||
provides,
|
||||
requires,
|
||||
imports,
|
||||
} = info;
|
||||
|
||||
let declared_name: InlinableString = "".into();
|
||||
|
||||
let mut imported: Vec<(QualifiedModuleName, Vec<Ident>, Region)> =
|
||||
|
@ -3149,7 +3172,7 @@ fn send_header_two<'a>(
|
|||
package_qualified_imported_modules,
|
||||
deps_by_name,
|
||||
exposes: exposed,
|
||||
header_src: "#builtin effect header",
|
||||
header_src,
|
||||
parse_state,
|
||||
exposed_imports: scope,
|
||||
module_timing,
|
||||
|
@ -3278,21 +3301,27 @@ fn fabricate_pkg_config_module<'a>(
|
|||
module_ids: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||
ident_ids_by_module: Arc<Mutex<MutMap<ModuleId, IdentIds>>>,
|
||||
header: &PlatformHeader<'a>,
|
||||
header_src: &'a str,
|
||||
module_timing: ModuleTiming,
|
||||
) -> (ModuleId, Msg<'a>) {
|
||||
let provides: &'a [Located<ExposesEntry<'a, &'a str>>] =
|
||||
header.provides.clone().into_bump_slice();
|
||||
|
||||
let info = PlatformHeaderInfo {
|
||||
filename,
|
||||
is_root_module: false,
|
||||
shorthand,
|
||||
header_src,
|
||||
app_module_id,
|
||||
packages: &[],
|
||||
provides,
|
||||
requires: header.requires.clone().into_bump_slice(),
|
||||
imports: header.imports.clone().into_bump_slice(),
|
||||
};
|
||||
|
||||
send_header_two(
|
||||
arena,
|
||||
filename,
|
||||
false,
|
||||
shorthand,
|
||||
app_module_id,
|
||||
&[],
|
||||
provides,
|
||||
header.requires.clone().into_bump_slice(),
|
||||
header.imports.clone().into_bump_slice(),
|
||||
info,
|
||||
parse_state,
|
||||
module_ids,
|
||||
ident_ids_by_module,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue