Refactor range reporting system to be a simple Source

This commit is contained in:
Eduardo Sandalo Porto 2024-08-15 19:07:02 -03:00
parent e263c98e6e
commit d67080b631
138 changed files with 329 additions and 195 deletions

View File

@ -1,3 +1,4 @@
use itertools::Itertools;
use TSPL::ParseError;
use crate::fun::{display::DisplayFn, Name, Source};
@ -33,7 +34,7 @@ pub struct DiagnosticsConfig {
pub struct Diagnostic {
pub message: String,
pub severity: Severity,
pub span: Option<FileSpan>,
pub source: Source,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
@ -74,30 +75,29 @@ impl Diagnostics {
Self { err_counter: 0, diagnostics: Default::default(), config }
}
pub fn add_parsing_error(&mut self, err: impl std::fmt::Display, span: FileSpan) {
pub fn add_parsing_error(&mut self, err: impl std::fmt::Display, source: Source) {
self.err_counter += 1;
self.add_diagnostic(err, Severity::Error, DiagnosticOrigin::Parsing, Some(span));
self.add_diagnostic(err, Severity::Error, DiagnosticOrigin::Parsing, source);
}
pub fn add_book_error(&mut self, err: impl std::fmt::Display) {
self.err_counter += 1;
self.add_diagnostic(err, Severity::Error, DiagnosticOrigin::Book, None);
self.add_diagnostic(err, Severity::Error, DiagnosticOrigin::Book, Default::default());
}
pub fn add_function_error(&mut self, err: impl std::fmt::Display, name: Name, source: Option<&Source>) {
pub fn add_function_error(&mut self, err: impl std::fmt::Display, name: Name, source: Source) {
self.err_counter += 1;
let span = source.and_then(|src| src.span()).map(|s| FileSpan::new(s, None));
self.add_diagnostic(
err,
Severity::Error,
DiagnosticOrigin::Function(name.def_name_from_generated()),
span,
source,
);
}
pub fn add_inet_error(&mut self, err: impl std::fmt::Display, def_name: String) {
self.err_counter += 1;
self.add_diagnostic(err, Severity::Error, DiagnosticOrigin::Inet(def_name), None);
self.add_diagnostic(err, Severity::Error, DiagnosticOrigin::Inet(def_name), Default::default());
}
pub fn add_function_warning(
@ -105,14 +105,18 @@ impl Diagnostics {
warn: impl std::fmt::Display,
warn_type: WarningType,
def_name: Name,
source: Option<&Source>,
source: Source,
) {
let severity = self.config.warning_severity(warn_type);
if severity == Severity::Error {
self.err_counter += 1;
}
let span = source.and_then(|src| src.span()).map(|s| FileSpan::new(s, None));
self.add_diagnostic(warn, severity, DiagnosticOrigin::Function(def_name.def_name_from_generated()), span);
self.add_diagnostic(
warn,
severity,
DiagnosticOrigin::Function(def_name.def_name_from_generated()),
source,
);
}
pub fn add_book_warning(&mut self, warn: impl std::fmt::Display, warn_type: WarningType) {
@ -120,7 +124,7 @@ impl Diagnostics {
if severity == Severity::Error {
self.err_counter += 1;
}
self.add_diagnostic(warn, severity, DiagnosticOrigin::Book, None);
self.add_diagnostic(warn, severity, DiagnosticOrigin::Book, Default::default());
}
pub fn add_diagnostic(
@ -128,9 +132,9 @@ impl Diagnostics {
msg: impl std::fmt::Display,
severity: Severity,
orig: DiagnosticOrigin,
range: Option<FileSpan>,
source: Source,
) {
let diag = Diagnostic { message: msg.to_string(), severity, span: range };
let diag = Diagnostic { message: msg.to_string(), severity, source };
self.diagnostics.entry(orig).or_default().push(diag)
}
@ -142,7 +146,7 @@ impl Diagnostics {
match result {
Ok(t) => Some(t),
Err(e) => {
self.add_function_error(e, def_name, None);
self.add_function_error(e, def_name, Default::default());
None
}
}
@ -189,52 +193,90 @@ impl Diagnostics {
/// Returns a Display that prints the diagnostics with one of the given severities.
pub fn display_with_severity(&self, severity: Severity) -> impl std::fmt::Display + '_ {
DisplayFn(move |f| {
fn filter<'a>(
errs: impl IntoIterator<Item = &'a Diagnostic>,
severity: Severity,
) -> impl Iterator<Item = &'a Diagnostic> {
errs.into_iter().filter(move |err| err.severity == severity)
}
// We want to print diagnostics information somewhat like this:
// ```
// In file A :
// In definition X :
// {error}
// In definition Y :
// {error}
//
// In file B :
// In compiled Inet Z :
// {error}
// {...}
// ```
// The problem is, diagnostics data is currently structured as a mapping from something like
// DiagnosticOrigin to (DiagnosticMessage, DiagnosticFile), and we would need something
// like a mapping from DiagnosticFile to DiagnosticOrigin to DiagnosticMessage in order
// to print it cleanly. We might want to change it later to have this structure,
// but meanwhile, we do the transformations below to make the goal possible.
let mut has_msg = false;
for (orig, errs) in &self.diagnostics {
let mut errs = filter(errs, severity).peekable();
if errs.peek().is_some() {
match orig {
DiagnosticOrigin::Parsing => {
for err in errs {
writeln!(f, "{err}")?;
}
}
DiagnosticOrigin::Book => {
for err in errs {
writeln!(f, "{err}")?;
}
}
DiagnosticOrigin::Function(nam) => {
writeln!(f, "\x1b[1mIn definition '\x1b[4m{}\x1b[0m\x1b[1m':\x1b[0m", nam)?;
for err in errs {
writeln!(f, "{:ERR_INDENT_SIZE$}{err}", "")?;
}
}
DiagnosticOrigin::Inet(nam) => {
writeln!(f, "\x1b[1mIn compiled inet '\x1b[4m{}\x1b[0m\x1b[1m':\x1b[0m", nam)?;
for err in errs {
writeln!(f, "{:ERR_INDENT_SIZE$}{err}", "")?;
}
}
DiagnosticOrigin::Readback => {
writeln!(f, "\x1b[1mDuring readback:\x1b[0m")?;
for err in errs {
writeln!(f, "{:ERR_INDENT_SIZE$}{err}", "")?;
// Flatten Iter<(Origin, Vec<Diagnostic>)> into Iter<(Origin, Diagnostic)>
let diagnostics = self
.diagnostics
.iter()
.flat_map(|(origin, diagnostics)| diagnostics.iter().map(move |diagnostic| (origin, diagnostic)));
// Remove diagnostics with unwanted Severity
let diagnostics = diagnostics.filter(|(_, diag)| diag.severity == severity);
// Group diagnostics by their file names
let file_groups = diagnostics.group_by(|diag| diag.1.source.file.as_ref());
// Now, we have a mapping from DiagnosticFile to (DiagnosticOrigin, DiagnosticMessage).
for (file, origins_and_diagnostics) in &file_groups {
// We don't have to check if the amount of diagnostics in this file is greater than 0,
// since we will only get a file if it was included in a diagnostic.
match &file {
Some(name) => writeln!(f, "\x1b[1mIn \x1b[4m{}\x1b[0m\x1b[1m :\x1b[0m", name)?,
None => writeln!(f, "\x1b[1mDuring execution :\x1b[0m")?,
};
// Group errors by their origin
let origin_groups = origins_and_diagnostics.group_by(|(origin, _)| *origin);
let mut has_msg = false;
// Finally, we have our mapping of DiagnosticOrigin to DiagnosticMessage back.
for (origin, origins_and_diagnostics) in &origin_groups {
// We don't care about DiagnosticOrigins here, so remove them.
let mut diagnostics = origins_and_diagnostics.map(|(_, diag)| diag).peekable();
if diagnostics.peek().is_some() {
match origin {
DiagnosticOrigin::Parsing => {
for err in diagnostics {
writeln!(f, "{err}")?;
}
}
DiagnosticOrigin::Book => {
for err in diagnostics {
writeln!(f, "{err}")?;
}
}
DiagnosticOrigin::Function(nam) => {
writeln!(f, "\x1b[1mIn definition '\x1b[4m{}\x1b[0m\x1b[1m':\x1b[0m", nam)?;
for err in diagnostics {
writeln!(f, "{:ERR_INDENT_SIZE$}{err}", "")?;
}
}
DiagnosticOrigin::Inet(nam) => {
writeln!(f, "\x1b[1mIn compiled inet '\x1b[4m{}\x1b[0m\x1b[1m':\x1b[0m", nam)?;
for err in diagnostics {
writeln!(f, "{:ERR_INDENT_SIZE$}{err}", "")?;
}
}
DiagnosticOrigin::Readback => {
writeln!(f, "\x1b[1mDuring readback:\x1b[0m")?;
for err in diagnostics {
writeln!(f, "{:ERR_INDENT_SIZE$}{err}", "")?;
}
}
}
has_msg = true;
}
has_msg = true;
}
}
if has_msg {
writeln!(f)?;
if has_msg {
writeln!(f)?;
}
}
Ok(())
})
@ -267,7 +309,7 @@ impl From<String> for Diagnostics {
Self {
diagnostics: BTreeMap::from_iter([(
DiagnosticOrigin::Book,
vec![Diagnostic { message: value, severity: Severity::Error, span: None }],
vec![Diagnostic { message: value, severity: Severity::Error, source: Default::default() }],
)]),
..Default::default()
}
@ -284,7 +326,7 @@ impl From<ParseError> for Diagnostics {
Self {
diagnostics: BTreeMap::from_iter([(
DiagnosticOrigin::Parsing,
vec![Diagnostic { message: value.into(), severity: Severity::Error, span: None }],
vec![Diagnostic { message: value.into(), severity: Severity::Error, source: Default::default() }],
)]),
..Default::default()
}
@ -331,12 +373,7 @@ impl Default for DiagnosticsConfig {
impl Display for Diagnostic {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
// TODO: this could be problematic when printing multiple errors from the same file
// currently, there shouldn't be any `Diagnostics` with multiple problems `FileSpan`s
match &self.span {
Some(FileSpan { file: Some(file), .. }) => write!(f, "In {} :\n{}", file, self.message),
_ => write!(f, "{}", self.message),
}
write!(f, "{}", self.message)
}
}
@ -443,17 +480,3 @@ impl TextSpan {
TextSpan::new(TextLocation::new(start_line, start_char), TextLocation::new(end_line, end_char))
}
}
#[derive(Debug, Clone, Hash, PartialEq, PartialOrd, Ord, Eq)]
pub struct FileSpan {
pub span: TextSpan,
// Storing files as Strings, could be done as file IDs in the future
// This is currently optional, we might want to change it later
pub file: Option<String>,
}
impl FileSpan {
pub fn new(span: TextSpan, origin: Option<&str>) -> Self {
FileSpan { span, file: origin.map(|s| s.into()) }
}
}

View File

@ -17,7 +17,7 @@ impl Ctx<'_> {
self.info.add_function_error(
format!("Reference to undefined function '{unbound}'"),
def.name.clone(),
Some(&def.source),
def.source.clone(),
);
}
}

View File

@ -28,7 +28,7 @@ impl Ctx<'_> {
}
for err in errs {
self.info.add_function_error(err, def_name.clone(), Some(&def.source));
self.info.add_function_error(err, def_name.clone(), def.source.clone());
}
}

View File

@ -1,9 +1,9 @@
use super::{
parser::{ParseBook, TermParser},
Book, Name,
Book, Name, Source, SourceKind,
};
use crate::{
diagnostics::{Diagnostics, DiagnosticsConfig, FileSpan, TextSpan},
diagnostics::{Diagnostics, DiagnosticsConfig, TextSpan},
imports::PackageLoader,
};
use std::path::Path;
@ -44,7 +44,9 @@ pub fn do_parse_book(code: &str, origin: &Path, mut book: ParseBook) -> Result<P
TermParser::new(code).parse_book(book, false).map_err(|err| {
let mut diagnostics = Diagnostics::default();
let span = TextSpan::from_byte_span(code, err.span.0..err.span.1);
diagnostics.add_parsing_error(err, FileSpan { span, file: Some(origin.to_string_lossy().into()) });
let source =
Source { file: Some(origin.to_string_lossy().into()), span: Some(span), kind: SourceKind::User };
diagnostics.add_parsing_error(err, source);
diagnostics
})
}

View File

@ -69,14 +69,24 @@ pub struct Definition {
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Source {
pub struct Source {
pub file: Option<String>,
pub span: Option<TextSpan>,
pub kind: SourceKind,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SourceKind {
/// Built into the language.
Builtin,
/// Was generated by the compiler.
Generated,
/// Source code location from the current book.
Local(TextSpan),
/// Imported from another package.
/// Source code from a local book.
User,
/// Source code from an imported book.
Imported,
/// Unknown by the compiler at this stage.
Unknown,
}
/// An HVM native definition.
@ -1022,7 +1032,8 @@ impl Definition {
}
pub fn new_gen(name: Name, rules: Vec<Rule>, builtin: bool) -> Self {
let source = if builtin { Source::Builtin } else { Source::Generated };
let kind = if builtin { SourceKind::Builtin } else { SourceKind::Generated };
let source = Source { file: None, span: None, kind };
Self { name, rules, source }
}
@ -1117,18 +1128,17 @@ impl Book {
impl Source {
pub fn is_builtin(&self) -> bool {
matches!(self, Source::Builtin)
matches!(self.kind, SourceKind::Builtin)
}
pub fn is_local(&self) -> bool {
matches!(self, Source::Local(..))
matches!(self.kind, SourceKind::User)
}
}
pub fn span(&self) -> Option<TextSpan> {
match self {
Source::Local(span) => Some(*span),
_ => None,
}
impl Default for Source {
fn default() -> Self {
Self { file: None, span: None, kind: SourceKind::Unknown }
}
}

View File

@ -550,7 +550,12 @@ impl Reader<'_> {
for (err, count) in err_counts {
let count_msg = if count > 1 { format!(" ({count} occurrences)") } else { "".to_string() };
let msg = format!("{}{}", err, count_msg);
diagnostics.add_diagnostic(msg.as_str(), Severity::Warning, DiagnosticOrigin::Readback, None);
diagnostics.add_diagnostic(
msg.as_str(),
Severity::Warning,
DiagnosticOrigin::Readback,
Default::default(),
);
}
}

View File

@ -15,6 +15,8 @@ use indexmap::IndexMap;
use itertools::Itertools;
use TSPL::{ParseError, Parser};
use super::SourceKind;
type FunDefinition = super::Definition;
type ImpDefinition = crate::imp::Definition;
@ -165,8 +167,12 @@ impl<'a> TermParser<'a> {
self.index = rewind_index;
let (nam, ctrs) = self.parse_datatype()?;
let end_idx = *self.index();
let span = TextSpan::from_byte_span(self.input(), ini_idx..end_idx);
let source = if builtin { Source::Builtin } else { Source::Local(span) };
let span = Some(TextSpan::from_byte_span(self.input(), ini_idx..end_idx));
let kind = if builtin { SourceKind::Builtin } else { SourceKind::User };
let file = Some(book.source.to_string());
let source = Source { file, span, kind };
let adt = Adt { ctrs, source };
self.add_fun_type(&mut book, nam, adt, ini_idx..end_idx)?;
indent = self.advance_newlines()?;
@ -278,8 +284,12 @@ impl<'a> TermParser<'a> {
let body = p.parse_net()?;
*self.index() = ini_idx + *p.index();
let end_idx = *self.index();
let span = TextSpan::from_byte_span(self.input(), ini_idx..end_idx);
let source = if builtin { Source::Builtin } else { Source::Local(span) };
let span = Some(TextSpan::from_byte_span(self.input(), ini_idx..end_idx));
let kind = if builtin { SourceKind::Builtin } else { SourceKind::User };
let file = None; // should we pass the book's source here?
let source = Source { file, span, kind };
let def = HvmDefinition { name: name.clone(), body, source };
Ok(def)
}
@ -653,8 +663,9 @@ impl<'a> TermParser<'a> {
if name == "def" {
// parse the nxt def term.
self.index = nxt_def;
let span = TextSpan::from_byte_span(self.input(), nxt_def..*self.index());
let def = FunDefinition::new(name, rules, Source::Local(span));
let span = Some(TextSpan::from_byte_span(self.input(), nxt_def..*self.index()));
let source = Source { span, file: None, kind: SourceKind::User };
let def = FunDefinition::new(name, rules, source);
return Ok(Term::Def { def, nxt: Box::new(self.parse_term()?) });
}
if name == cur_name {
@ -672,8 +683,8 @@ impl<'a> TermParser<'a> {
}
}
let nxt = self.parse_term()?;
let span = TextSpan::from_byte_span(self.input(), nxt_term..*self.index());
let def = FunDefinition::new(cur_name, rules, Source::Local(span));
let span = Some(TextSpan::from_byte_span(self.input(), nxt_term..*self.index()));
let def = FunDefinition::new(cur_name, rules, Source { span, file: None, kind: SourceKind::User });
return Ok(Term::Def { def, nxt: Box::new(nxt) });
}
@ -938,7 +949,7 @@ impl<'a> TermParser<'a> {
// Continuing with a new rule to the current definition
(Some(def), Some(last_rule)) if last_rule == name => {
def.rules.push(rule);
if let Source::Local(s) = &mut def.source {
if let Some(s) = &mut def.source.span {
s.end = TextLocation::from_byte_loc(self.input(), span.end);
}
}
@ -955,8 +966,10 @@ impl<'a> TermParser<'a> {
// Adding the first rule of a new definition
(None, _) => {
self.check_top_level_redefinition(name, book, span.clone())?;
let span = TextSpan::from_byte_span(self.input(), span.start..span.end);
let source = if builtin { Source::Builtin } else { Source::Local(span) };
let span = Some(TextSpan::from_byte_span(self.input(), span.start..span.end));
let file = Some(book.source.to_string());
let kind = if builtin { SourceKind::Builtin } else { SourceKind::User };
let source = Source { file, span, kind };
book.fun_defs.insert(name.clone(), FunDefinition::new(name.clone(), vec![rule], source));
}
}
@ -971,8 +984,10 @@ impl<'a> TermParser<'a> {
builtin: bool,
) -> ParseResult<()> {
self.check_top_level_redefinition(&def.name, book, span.clone())?;
let span = TextSpan::from_byte_span(self.input(), span.start..span.end);
let source = if builtin { Source::Builtin } else { Source::Local(span) };
let span = Some(TextSpan::from_byte_span(self.input(), span.start..span.end));
let kind = if builtin { SourceKind::Builtin } else { SourceKind::User };
let file = Some(book.source.to_string());
let source = Source { file, span, kind };
def.source = source;
book.imp_defs.insert(def.name.clone(), def);
Ok(())
@ -988,15 +1003,19 @@ impl<'a> TermParser<'a> {
&mut self,
enum_: Enum,
book: &mut ParseBook,
span: Range<usize>,
range: Range<usize>,
builtin: bool,
) -> ParseResult<()> {
self.check_type_redefinition(&enum_.name, book, span.clone())?;
let text_span = TextSpan::from_byte_span(self.input(), span.start..span.end);
let source = if builtin { Source::Builtin } else { Source::Local(text_span) };
self.check_type_redefinition(&enum_.name, book, range.clone())?;
let span = Some(TextSpan::from_byte_span(self.input(), range.start..range.end));
let kind = if builtin { SourceKind::Builtin } else { SourceKind::User };
let file = Some(book.source.to_string());
let source = Source { file, span, kind };
let mut adt = Adt { ctrs: Default::default(), source };
for variant in enum_.variants {
self.check_top_level_redefinition(&enum_.name, book, span.clone())?;
self.check_top_level_redefinition(&enum_.name, book, range.clone())?;
book.ctrs.insert(variant.name.clone(), enum_.name.clone());
adt.ctrs.insert(variant.name, variant.fields);
}
@ -1042,8 +1061,12 @@ impl<'a> TermParser<'a> {
) -> ParseResult<()> {
self.check_type_redefinition(&obj.name, book, span.clone())?;
self.check_top_level_redefinition(&obj.name, book, span.clone())?;
let span = TextSpan::from_byte_span(self.input(), span.start..span.end);
let source = if builtin { Source::Builtin } else { Source::Local(span) };
let span = Some(TextSpan::from_byte_span(self.input(), span.start..span.end));
let kind = if builtin { SourceKind::Builtin } else { SourceKind::User };
let file = Some(book.source.to_string());
let source = Source { file, span, kind };
let mut adt = Adt { ctrs: Default::default(), source };
book.ctrs.insert(obj.name.clone(), obj.name.clone());
adt.ctrs.insert(obj.name.clone(), obj.fields);

View File

@ -26,7 +26,7 @@ impl Ctx<'_> {
self.info.add_function_error(
format!("Expected the entrypoint function to have only one rule, found {n_rules}."),
entrypoint.clone(),
None,
main_def.source.clone(),
);
}
@ -39,7 +39,7 @@ impl Ctx<'_> {
self.info.add_function_error(
format!("Expected the entrypoint function to only have variable patterns, found '{pat}'."),
entrypoint.clone(),
None,
main_def.source.clone(),
);
}
}

View File

@ -1,6 +1,6 @@
use crate::{
diagnostics::WarningType,
fun::{Book, Ctx, Name, Source, Term},
fun::{Book, Ctx, Name, SourceKind, Term},
maybe_grow,
};
use hvm::ast::{Net, Tree};
@ -77,12 +77,12 @@ impl Ctx<'_> {
// Prune if `prune_all`, otherwise show a warning.
if prune_all {
rm_def(self.book, &def);
} else if !def.is_generated() && !matches!(src, Source::Generated) {
} else if !def.is_generated() && !matches!(src.kind, SourceKind::Generated) {
self.info.add_function_warning(
"Definition is unused.",
WarningType::UnusedDefinition,
def,
Some(&src),
src,
);
}
}

View File

@ -16,7 +16,7 @@ impl Ctx<'_> {
let mut fresh = 0;
for rule in def.rules.iter_mut() {
if let Err(err) = rule.body.desugar_bend(&def.name, &mut fresh, &mut new_defs, &def.source) {
self.info.add_function_error(err, def.name.clone(), Some(&def.source));
self.info.add_function_error(err, def.name.clone(), def.source.clone());
break;
}
}

View File

@ -43,7 +43,7 @@ impl Ctx<'_> {
&def.source,
);
if let Err(e) = res {
self.info.add_function_error(e, def.name.clone(), Some(&def.source));
self.info.add_function_error(e, def.name.clone(), def.source.clone());
}
}
}

View File

@ -24,13 +24,13 @@ impl Ctx<'_> {
DesugarMatchDefErr::AdtNotExhaustive { .. }
| DesugarMatchDefErr::NumMissingDefault
| DesugarMatchDefErr::TypeMismatch { .. } => {
self.info.add_function_error(err, def_name.clone(), Some(&def.source))
self.info.add_function_error(err, def_name.clone(), def.source.clone())
}
DesugarMatchDefErr::RepeatedBind { .. } => self.info.add_function_warning(
err,
WarningType::RepeatedBind,
def_name.clone(),
Some(&def.source),
def.source.clone(),
),
}
}

View File

@ -11,7 +11,7 @@ impl Ctx<'_> {
for def in self.book.defs.values_mut() {
for rule in def.rules.iter_mut() {
if let Err(err) = rule.body.desugar_open(&self.book.adts) {
self.info.add_function_error(err, def.name.clone(), Some(&def.source));
self.info.add_function_error(err, def.name.clone(), def.source.clone());
}
}
}

View File

@ -15,7 +15,7 @@ impl Ctx<'_> {
for def in self.book.defs.values_mut() {
for rule in def.rules.iter_mut() {
if let Err(e) = rule.body.desugar_with_blocks(None, &def_names) {
self.info.add_function_error(e, def.name.clone(), Some(&def.source));
self.info.add_function_error(e, def.name.clone(), def.source.clone());
}
}
}

View File

@ -19,7 +19,7 @@ impl Ctx<'_> {
}
for err in errs {
self.info.add_function_error(err, def.name.clone(), Some(&def.source));
self.info.add_function_error(err, def.name.clone(), def.source.clone());
}
}

View File

@ -51,25 +51,25 @@ impl Ctx<'_> {
for err in errs {
match err {
FixMatchErr::AdtMismatch { .. } | FixMatchErr::NonExhaustiveMatch { .. } => {
self.info.add_function_error(err, def.name.clone(), Some(&def.source))
self.info.add_function_error(err, def.name.clone(), def.source.clone())
}
FixMatchErr::IrrefutableMatch { .. } => self.info.add_function_warning(
err,
WarningType::IrrefutableMatch,
def.name.clone(),
Some(&def.source),
def.source.clone(),
),
FixMatchErr::UnreachableMatchArms { .. } => self.info.add_function_warning(
err,
WarningType::UnreachableMatch,
def.name.clone(),
Some(&def.source),
def.source.clone(),
),
FixMatchErr::RedundantArm { .. } => self.info.add_function_warning(
err,
WarningType::RedundantMatch,
def.name.clone(),
Some(&def.source),
def.source.clone(),
),
}
}

View File

@ -23,7 +23,7 @@ pub fn check_net_sizes(
diagnostics.add_function_error(
format!("Definition is too large for HVM {target_lang} (size={nodes}, max size={net_size_bound}). Please break it into smaller pieces."),
Name::new(name),
None
Default::default()
);
}
}

View File

@ -1,7 +1,7 @@
use crate::{
fun::{
parser::{is_num_char, Indent, ParseResult, ParserCommons},
CtrField, Name, Num, Op, STRINGS,
CtrField, Name, Num, Op, Source, SourceKind, STRINGS,
},
imp::{AssignPattern, Definition, Enum, Expr, InPlaceOp, MatchArm, Stmt, Variant},
maybe_grow,
@ -1037,7 +1037,8 @@ impl<'a> PyParser<'a> {
indent.exit_level();
// Temporary source, should be overwritten later
let def = Definition { name, params, body, source: crate::fun::Source::Generated };
let source = Source { file: None, span: None, kind: SourceKind::Generated };
let def = Definition { name, params, body, source };
Ok((def, nxt_indent))
}

View File

@ -32,7 +32,7 @@ impl Definition {
pub fn to_fun(self) -> Result<fun::Definition, Diagnostics> {
let body = self.body.into_fun().map_err(|e| {
let mut diags = Diagnostics::default();
diags.add_function_error(e, self.name.clone(), Some(&self.source));
diags.add_function_error(e, self.name.clone(), self.source.clone());
diags
})?;
@ -43,7 +43,7 @@ impl Definition {
diags.add_function_error(
"Function doesn't end with a return statement",
self.name,
Some(&self.source),
self.source.clone(),
);
return Err(diags);
}

View File

@ -1,7 +1,7 @@
use super::{BindMap, ImportsMap, PackageLoader};
use crate::{
diagnostics::{Diagnostics, DiagnosticsConfig},
fun::{parser::ParseBook, Adt, Book, Definition, HvmDefinition, Name, Rule, Source, Term},
fun::{parser::ParseBook, Adt, Book, Definition, HvmDefinition, Name, Rule, Source, SourceKind, Term},
imp::{self, Expr, Stmt},
imports::packages::Packages,
};
@ -166,7 +166,7 @@ impl ParseBook {
// starting with `__` if not imported by the main book.
for (mut name, mut adt) in adts {
if adt.source.is_local() {
adt.source = Source::Imported;
adt.source.kind = SourceKind::Imported;
name = Name::new(format!("{}/{}", src, name));
let mangle_name = !main_imports.contains_source(&name);
@ -217,7 +217,7 @@ impl ParseBook {
// Applies the binds for the new names for every definition
for (_, def) in self.local_defs_mut() {
def.apply_binds(false, &canonical_map);
*def.source_mut() = Source::Imported;
def.source_mut().kind = SourceKind::Imported;
}
}
}

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/desugar_merge.bend
---
Warnings:
In tests/golden_tests/cli/desugar_merge.bend :
In definition 'Z':
Definition is unused.

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/desugar_pretty.bend
---
Warnings:
In tests/golden_tests/cli/desugar_pretty.bend :
In definition 'Foo':
Definition is unused.

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/input_file_not_found.bend
---
Errors:
During execution :
The file 'tests/golden_tests/missing_dir/input_file_not_found.bend' was not found.

View File

@ -3,9 +3,11 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/warn_and_err.bend
---
Warnings:
In tests/golden_tests/cli/warn_and_err.bend :
In definition 'Foo':
Repeated bind in pattern matching rule: 'a'.
Errors:
In tests/golden_tests/cli/warn_and_err.bend :
In definition 'Main':
Unbound variable 'a'.

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/360_no_scope.bend
---
Errors:
In tests/golden_tests/compile_file/360_no_scope.bend :
In tests/golden_tests/compile_file/360_no_scope.bend :
- expected: '='
- detected: end of input
 6 |  

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/ask_outside_do.bend
---
Errors:
In tests/golden_tests/compile_file/ask_outside_do.bend :
In definition 'main':
Monadic bind operation 'x <- ...' used outside of a `do` block.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/cyclic_global_lam.bend
---
Errors:
During execution :
In compiled inet 'main':
Found term that compiles into an inet with a vicious cycle

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/elif_no_else.bend
---
Errors:
In tests/golden_tests/compile_file/elif_no_else.bend :
In tests/golden_tests/compile_file/elif_no_else.bend :
- expected: 'else' or 'elif'
- detected: end of input
 6 |  

View File

@ -3,6 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/error_data_def_name.bend
---
Errors:
In tests/golden_tests/compile_file/error_data_def_name.bend :
In tests/golden_tests/compile_file/error_data_def_name.bend :
Redefinition of constructor 'A/A'.
 2 | A/A = 0

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/error_messages.bend
---
Errors:
In tests/golden_tests/compile_file/error_messages.bend :
In definition 'Foo':
Unbound constructor 'C' in pattern matching rule.
Unbound constructor 'D' in pattern matching rule.

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/just_a_name.bend
---
Errors:
In tests/golden_tests/compile_file/just_a_name.bend :
In tests/golden_tests/compile_file/just_a_name.bend :
- expected: pattern or '='
- detected: end of input
 1 | asdf

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/just_data.bend
---
Errors:
In tests/golden_tests/compile_file/just_data.bend :
In tests/golden_tests/compile_file/just_data.bend :
- expected: datatype name
- detected: end of input
 1 | type 

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/just_paren.bend
---
Errors:
In tests/golden_tests/compile_file/just_paren.bend :
In tests/golden_tests/compile_file/just_paren.bend :
- expected: function name
- detected: end of input
 2 | ( 

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/just_rule_paren.bend
---
Errors:
In tests/golden_tests/compile_file/just_rule_paren.bend :
In tests/golden_tests/compile_file/just_rule_paren.bend :
- expected: '='
- detected: end of input
 1 | (rule) 

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/mismatched_ask_statements.bend
---
Errors:
In tests/golden_tests/compile_file/mismatched_ask_statements.bend :
In definition 'main':
'match' arms end with different assignments.

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/missing_adt_eq.bend
---
Errors:
In tests/golden_tests/compile_file/missing_adt_eq.bend :
In tests/golden_tests/compile_file/missing_adt_eq.bend :
- expected: '='
- detected: end of input
 1 | type Adt 

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/missing_ctrs.bend
---
Errors:
In tests/golden_tests/compile_file/missing_ctrs.bend :
In tests/golden_tests/compile_file/missing_ctrs.bend :
- expected: datatype constructor name
- detected: end of input
 1 | type Adt = 

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/missing_pat.bend
---
Errors:
In tests/golden_tests/compile_file/missing_pat.bend :
In tests/golden_tests/compile_file/missing_pat.bend :
- expected: name or '*'
- detected:
 2 | : *

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/nested_ctr_wrong_arity.bend
---
Errors:
In tests/golden_tests/compile_file/nested_ctr_wrong_arity.bend :
In definition 'fst_fst':
Incorrect arity for constructor 'Pair/Pair' of type 'Pair' in pattern matching rule. Expected 2 fields, found 1

View File

@ -3,6 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/number_too_large.bend
---
Errors:
In tests/golden_tests/compile_file/number_too_large.bend :
In tests/golden_tests/compile_file/number_too_large.bend :
Number literal outside of range for U24.
 1 | main = 0x10000000

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/ref_to_main.bend
---
Errors:
During execution :
In definition 'Foo':
Main definition can't be referenced inside the program.

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/repeated_bind_rule.bend
---
Warnings:
In tests/golden_tests/compile_file/repeated_bind_rule.bend :
In definition 'Foo':
Repeated bind in pattern matching rule: 'a'.

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/switch_all_patterns.bend
---
Errors:
In tests/golden_tests/compile_file/switch_all_patterns.bend :
In tests/golden_tests/compile_file/switch_all_patterns.bend :
- expected: '0'
- detected:
 7 | _: x-1

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/switch_incomplete.bend
---
Errors:
In tests/golden_tests/compile_file/switch_incomplete.bend :
In tests/golden_tests/compile_file/switch_incomplete.bend :
- expected: term
- detected:
 2 | main = switch {}

View File

@ -3,6 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/top_level_name_slashslash.bend
---
Errors:
In tests/golden_tests/compile_file/top_level_name_slashslash.bend :
In tests/golden_tests/compile_file/top_level_name_slashslash.bend :
Top-level names are not allowed to start with "//".
 4 | def //thisshouldfail():

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unbound_unscoped_var.bend
---
Errors:
In tests/golden_tests/compile_file/unbound_unscoped_var.bend :
In definition 'main':
Unbound unscoped variable '$a'.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unbound_var.bend
---
Errors:
In tests/golden_tests/compile_file/unbound_var.bend :
In definition 'main':
Unbound variable 'a'.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unbound_var_scope.bend
---
Errors:
In tests/golden_tests/compile_file/unbound_var_scope.bend :
In definition 'main':
Unbound variable 'b'.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unbound_with_tup_pattern.bend
---
Errors:
In tests/golden_tests/compile_file/unbound_with_tup_pattern.bend :
In definition 'Foo':
Unbound variable 'a'.

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unexpected_top_char.bend
---
Errors:
In tests/golden_tests/compile_file/unexpected_top_char.bend :
In tests/golden_tests/compile_file/unexpected_top_char.bend :
- expected: top-level definition
- detected:
 1 | *

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unscoped_dup_use.bend
---
Errors:
In tests/golden_tests/compile_file/unscoped_dup_use.bend :
In definition 'main':
Unscoped variable '$a' used more than once.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/unused_unscoped_bind.bend
---
Errors:
In tests/golden_tests/compile_file/unused_unscoped_bind.bend :
In definition 'main':
Unscoped variable from lambda 'λ$a' is never used.

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/variable_name_double_underscore.bend
---
Errors:
In tests/golden_tests/compile_file/variable_name_double_underscore.bend :
In tests/golden_tests/compile_file/variable_name_double_underscore.bend :
- expected: expression
- detected:
 2 | return __this_should_fail__(*)

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/vicious_circles.bend
---
Errors:
During execution :
In compiled inet 'disconnected_self_lam':
Found term that compiles into an inet with a vicious cycle
In compiled inet 'dup_self':

View File

@ -3,9 +3,11 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/warn_and_err.bend
---
Warnings:
In tests/golden_tests/compile_file/warn_and_err.bend :
In definition 'Foo':
Repeated bind in pattern matching rule: 'a'.
Errors:
In tests/golden_tests/compile_file/warn_and_err.bend :
In definition 'Main':
Unbound variable 'a'.

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/with_clause_parse_err.bend
---
Errors:
In tests/golden_tests/compile_file/with_clause_parse_err.bend :
In tests/golden_tests/compile_file/with_clause_parse_err.bend :
- expected: '{'
- detected:
 1 | main = @a @b switch b witha{

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/wrong_ctr_arity.bend
---
Errors:
In tests/golden_tests/compile_file/wrong_ctr_arity.bend :
In definition 'Bar':
Incorrect arity for constructor 'Boxed/Box' of type 'Boxed' in pattern matching rule. Expected 1 fields, found 2

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/wrong_ctr_var_arity.bend
---
Errors:
In tests/golden_tests/compile_file/wrong_ctr_var_arity.bend :
In definition 'foo':
Incorrect arity for constructor 'Tup/pair' of type 'Tup' in pattern matching rule. Expected 2 fields, found 0

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/wrong_nums.bend
---
Errors:
In tests/golden_tests/compile_file/wrong_nums.bend :
In tests/golden_tests/compile_file/wrong_nums.bend :
- expected: valid binary digit
- detected:
 1 | main = (+ 0b012345 0FA)

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/wrong_unicode_escape.bend
---
Errors:
In tests/golden_tests/compile_file/wrong_unicode_escape.bend :
In tests/golden_tests/compile_file/wrong_unicode_escape.bend :
- expected: '}'
- detected:
 1 | main = (String.cons '\u{1' "\u2}\u{zxcx}")

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/adt_string.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/adt_string.bend :
In tests/golden_tests/compile_file_o_all/adt_string.bend :
Redefinition of builtin (type) 'String'.
 1 | type String = S
 2 | 

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/bad_parens_making_erased_let.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/bad_parens_making_erased_let.bend :
In definition 'main':
Unbound variable 'two'.
Unbound variable 'qua'.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/cyclic_dup.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/cyclic_dup.bend :
In definition 'main':
Unbound variable 'y1'.

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/double_main.bend
---
Errors:
During execution :
File has both 'main' and 'Main' definitions.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/match_adt_non_exhaustive.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/match_adt_non_exhaustive.bend :
In definition 'main':
Non-exhaustive 'match' expression of type 'Maybe'. Case 'Maybe/Some' not covered.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend :
In definition 'Bool.and':
Non-exhaustive pattern matching rule. Constructor 'Bool/F' of type 'Bool' not covered

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/non_exhaustive_different_types.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/non_exhaustive_different_types.bend :
In definition 'foo':
Non-exhaustive pattern matching rule. Constructor 'b3/t3' of type 'b3' not covered

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/non_exhaustive_pattern.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/non_exhaustive_pattern.bend :
In definition 'Foo':
Non-exhaustive pattern matching rule. Constructor 'Type/A' of type 'Type' not covered

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/non_exhaustive_tree.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/non_exhaustive_tree.bend :
In definition 'Warp':
Non-exhaustive pattern matching rule. Constructor 'Tree/Leaf' of type 'Tree' not covered

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/repeated_name_trucation.bend
---
Warnings:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* long_name_that_truncates -> long_name_that_truncates

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/self_ref.bend
---
Warnings:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* Foo -> Foo
@ -32,5 +33,6 @@ To disable this check, use the "-Arecursion-cycle" compiler option.
Errors:
During execution :
During inlining:
infinite reference cycle in `@Foo`

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/tagged_dup.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/tagged_dup.bend :
In tests/golden_tests/compile_file_o_all/tagged_dup.bend :
- expected: '='
- detected:
 4 | let #i {e f} = @x x;

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/tagged_lam.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/tagged_lam.bend :
In tests/golden_tests/compile_file_o_all/tagged_lam.bend :
- expected: term
- detected: end of input
 2 |  

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/tagged_sup.bend
---
Errors:
In tests/golden_tests/compile_file_o_all/tagged_sup.bend :
In tests/golden_tests/compile_file_o_all/tagged_sup.bend :
- expected: top-level definition
- detected:
 2 | b = #i {λx x λx x}

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_no_all/bitonic_sort.bend
---
Errors:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* Down -> Flow -> Down
* Warp -> Warp

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_no_all/list_reverse.bend
---
Errors:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* concat -> concat
* reverse -> reverse

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_no_all/sum_tree.bend
---
Errors:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* gen -> gen
* sum -> sum

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_long/huge_tree.bend
---
Errors:
During execution :
In definition 'main':
Definition is too large for HVM C (size=120002, max size=4095). Please break it into smaller pieces.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_long/long_str_file.bend
---
Errors:
During execution :
In definition 'main':
Definition is too large for HVM C (size=1461028, max size=4095). Please break it into smaller pieces.

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/desugar_file/non_exaustive_limit.bend
---
Errors:
In tests/golden_tests/desugar_file/non_exaustive_limit.bend :
In definition 'Bar':
Non-exhaustive pattern matching rule. Constructor 'Foo/B' of type 'Foo' not covered

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/import_main.bend
---
Errors:
During execution :
Can not import the entry point of the program.

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/import_main2.bend
---
Errors:
During execution :
Can not import the entry point of the program.

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/import_main3.bend
---
Errors:
During execution :
Can not import the entry point of the program.

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/imports_alias_shadow.bend
---
Errors:
During execution :
The import 'lib/nums/two' shadows the imported name 'lib/nums/one'

View File

@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/imports_conflict.bend
---
Errors:
During execution :
The imported definition 'lib/a/b/C' conflicts with the definition 'lib/a/b/C'.
The imported constructor 'lib/a/b/C' conflicts with the definition 'lib/a/b/C'.

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/imports_file_and_dir_conflict.bend
---
Errors:
During execution :
Both file 'lib/file_and_dir.bend' and folder 'lib/file_and_dir' contains the import 'w'

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/imports_shadow.bend
---
Errors:
During execution :
The import 'lib/myFun/myFun' shadows the imported name 'lib/folder/myFun/myFun'

View File

@ -3,4 +3,5 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/import_system/imports_shadow2.bend
---
Errors:
During execution :
The import 'lib/folder/myFun/myFun' shadows the imported name 'lib/myFun/myFun'

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/mutual_recursion/a_b_c.bend
---
Errors:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* A -> B -> C -> A

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/mutual_recursion/merged.bend
---
Errors:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* Rec -> X -> Rec
* Rec -> Y -> Rec

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/mutual_recursion/multiple.bend
---
Errors:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* A -> B -> C -> A
* H -> I -> H

View File

@ -3,6 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/mutual_recursion/odd_even.bend
---
Errors:
During execution :
The following functions contain recursive cycles incompatible with HVM's strict evaluation:
* isEven -> isOdd -> isEven

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/bad_floating.bend
---
Errors:
In tests/golden_tests/parse_file/bad_floating.bend :
In tests/golden_tests/parse_file/bad_floating.bend :
- expected: newline
- detected:
 2 | return 0xA.0xA

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/bend_missing_else.bend
---
Errors:
In tests/golden_tests/parse_file/bend_missing_else.bend :
In tests/golden_tests/parse_file/bend_missing_else.bend :
- expected: 'else'
- detected:
 14 | def main():

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/fold_missing_case.bend
---
Errors:
In tests/golden_tests/parse_file/fold_missing_case.bend :
In tests/golden_tests/parse_file/fold_missing_case.bend :
- expected: 'case'
- detected: end of input
 4 |  

View File

@ -3,6 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/fun_def_name.bend
---
Errors:
In tests/golden_tests/parse_file/fun_def_name.bend :
In tests/golden_tests/parse_file/fun_def_name.bend :
Expected a rule with name 'aux'.
 4 | aux2 (List/Cons head tail) = (+ head (aux tail))

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/if_missing_else.bend
---
Errors:
In tests/golden_tests/parse_file/if_missing_else.bend :
In tests/golden_tests/parse_file/if_missing_else.bend :
- expected: 'else' or 'elif'
- detected: end of input
 5 |  

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/match_missing_case.bend
---
Errors:
In tests/golden_tests/parse_file/match_missing_case.bend :
In tests/golden_tests/parse_file/match_missing_case.bend :
- expected: 'case'
- detected: end of input
 4 |  

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/redefinition_builtin.bend
---
Errors:
In tests/golden_tests/parse_file/redefinition_builtin.bend :
In tests/golden_tests/parse_file/redefinition_builtin.bend :
Redefinition of builtin (function) 'Map/get'.
 1 | def Map/get(m):
 2 |  return m

View File

@ -3,7 +3,7 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/redefinition_ctr_with_fun.bend
---
Errors:
In tests/golden_tests/parse_file/redefinition_ctr_with_fun.bend :
In tests/golden_tests/parse_file/redefinition_ctr_with_fun.bend :
Redefinition of builtin (constructor) 'String/Cons'.
 1 | def String/Cons(x):
 2 |  return x

Some files were not shown because too many files have changed in this diff Show More