fixes imports bug found in Aleo Studio

This commit is contained in:
damirka 2021-06-24 18:40:46 +03:00
parent 8b7c1dc6cd
commit 40bc7aef8d
3 changed files with 7 additions and 6 deletions

View File

@ -94,10 +94,10 @@ impl ImportParserError {
}
///
/// Failed to find a library file for the current package.
/// Failed to find a main file for the current package.
///
pub fn expected_lib_file(entry: String, span: &Span) -> Self {
let message = format!("Expected library file `{}`.", entry,);
pub fn expected_main_file(entry: String, span: &Span) -> Self {
let message = format!("Expected main file at `{}`.", entry,);
Self::new_from_span(message, span)
}

View File

@ -72,6 +72,7 @@ impl<'a> ImportParser<'a> {
// Search for package name in `imports` directory
let mut imports_directory = path.clone();
imports_directory.pop(); // path leads to src/ folder, imports is one level below
imports_directory.push(IMPORTS_DIRECTORY_NAME);
// Read from local `src` directory or the current path

View File

@ -19,7 +19,7 @@ use leo_ast::{Program, Span};
use std::fs::DirEntry;
static LIBRARY_FILE: &str = "src/lib.leo";
static MAIN_FILE: &str = "src/main.leo";
impl<'a> ImportParser<'a> {
///
@ -39,10 +39,10 @@ impl<'a> ImportParser<'a> {
let mut file_path = package.path();
if file_type.is_dir() {
file_path.push(LIBRARY_FILE);
file_path.push(MAIN_FILE);
if !file_path.exists() {
return Err(ImportParserError::expected_lib_file(
return Err(ImportParserError::expected_main_file(
format!("{:?}", file_path.as_path()),
span,
));