hide internal functions from suggested hints on unknown modules/constructor/value.
Signed-off-by: KtorZ <matthias.benkort@gmail.com>
This commit is contained in:
parent
3db9828fe8
commit
b9052949f7
|
@ -11,7 +11,7 @@ authors = [
|
||||||
"Kasey White <kwhitemsg@gmail.com>",
|
"Kasey White <kwhitemsg@gmail.com>",
|
||||||
"KtorZ <matthias.benkort@gmail.com>",
|
"KtorZ <matthias.benkort@gmail.com>",
|
||||||
]
|
]
|
||||||
rust-version = "1.70.0"
|
rust-version = "1.80.0"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
IdGenerator,
|
IdGenerator,
|
||||||
};
|
};
|
||||||
|
use std::{collections::BTreeSet, sync::LazyLock};
|
||||||
|
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use std::{collections::HashMap, rc::Rc};
|
use std::{collections::HashMap, rc::Rc};
|
||||||
|
@ -25,6 +26,16 @@ use uplc::{
|
||||||
pub const PRELUDE: &str = "aiken";
|
pub const PRELUDE: &str = "aiken";
|
||||||
pub const BUILTIN: &str = "aiken/builtin";
|
pub const BUILTIN: &str = "aiken/builtin";
|
||||||
|
|
||||||
|
pub static INTERNAL_FUNCTIONS: LazyLock<BTreeSet<&'static str>> = LazyLock::new(|| {
|
||||||
|
let mut set = BTreeSet::new();
|
||||||
|
set.insert("diagnostic");
|
||||||
|
set.insert("do_from_int");
|
||||||
|
set.insert("encode_base16");
|
||||||
|
set.insert("enumerate");
|
||||||
|
set.insert("from_int");
|
||||||
|
set
|
||||||
|
});
|
||||||
|
|
||||||
/// Build a prelude that can be injected
|
/// Build a prelude that can be injected
|
||||||
/// into a compiler pipeline
|
/// into a compiler pipeline
|
||||||
pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
||||||
|
|
|
@ -796,8 +796,7 @@ impl<'a> Environment<'a> {
|
||||||
self.module_types
|
self.module_types
|
||||||
.keys()
|
.keys()
|
||||||
.filter_map(|t| {
|
.filter_map(|t| {
|
||||||
// Avoid leaking special internal types such as __ScriptContext or
|
// Avoid leaking special internal types in error hints.
|
||||||
// __ScriptPurpose.
|
|
||||||
if t.starts_with("__") {
|
if t.starts_with("__") {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -811,6 +810,9 @@ impl<'a> Environment<'a> {
|
||||||
self.scope
|
self.scope
|
||||||
.keys()
|
.keys()
|
||||||
.filter(|&t| PIPE_VARIABLE != t)
|
.filter(|&t| PIPE_VARIABLE != t)
|
||||||
|
// Avoid leaking internal functions in error hints.
|
||||||
|
.filter(|&t| !crate::builtins::INTERNAL_FUNCTIONS.contains(t.as_str()))
|
||||||
|
.filter(|&t| !t.starts_with("__") && !TypeConstructor::might_be(t))
|
||||||
.map(|t| t.to_string())
|
.map(|t| t.to_string())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -818,7 +820,9 @@ impl<'a> Environment<'a> {
|
||||||
pub fn local_constructor_names(&self) -> Vec<String> {
|
pub fn local_constructor_names(&self) -> Vec<String> {
|
||||||
self.scope
|
self.scope
|
||||||
.keys()
|
.keys()
|
||||||
.filter(|&t| t.chars().next().unwrap_or_default().is_uppercase())
|
// Avoid leaking internal constructors in error hints.
|
||||||
|
.filter(|&t| !t.starts_with("__"))
|
||||||
|
.filter(|&t| TypeConstructor::might_be(t))
|
||||||
.map(|t| t.to_string())
|
.map(|t| t.to_string())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue