Skip to content

Commit

Permalink
fix std load
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmindlin committed Jun 26, 2024
1 parent f32148e commit c275bfa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
history.txt
.DS_Store
11 changes: 9 additions & 2 deletions scout-interpreter/src/import.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::path::{Path, PathBuf};
use std::{
env,
path::{Path, PathBuf},
};

use scout_lexer::TokenKind;
use scout_parser::ast::{ExprKind, Identifier};
Expand Down Expand Up @@ -27,7 +30,11 @@ pub fn resolve_module(module: &ExprKind) -> Result<ResolvedMod, EvalError> {

fn resolve_std_file(ident: &Identifier) -> Result<PathBuf, EvalError> {
if *ident == Identifier::new("std".into()) {
let path = Path::new("scout-lib").to_owned();
let home = env::var("HOME").map_err(|_| EvalError::OSError)?;
let path = Path::new(&home)
.join("scout-lang")
.join("scout-lib")
.to_owned();
Ok(path)
} else {
Ok(Path::new(&ident.name).to_owned())
Expand Down
2 changes: 1 addition & 1 deletion scout-interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn eval_use_chain<'a>(
.to_str()
.ok_or(EvalError::InvalidImport)?
.to_string();
let dir_name = if dir_name_raw == String::from("scout-lib") {
let dir_name = if &dir_name_raw == "scout-lib" {
String::from("std")
} else {
dir_name_raw
Expand Down

0 comments on commit c275bfa

Please sign in to comment.