Skip to content

Commit

Permalink
Merge pull request #45 from coco33920/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
coco33920 authored May 20, 2024
2 parents d134a65 + b697796 commit feaa0a4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Version 3.0.1 : Bug fix
Fix stackoverflow on custom function call with same name

# Version 3.0.0 : Symbolic calculation!
Version 3.0.0, at last! (if you've seen the PR for it it's been sitting for more
than three weeks!)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mini-calc"
version = "3.0.0"
version = "3.0.1"
license = "GPL-3.0-or-later"
description = "A fully-featured minimalistic configurable rust calculator"
homepage = "https://calc.nwa2coco.fr"
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn load_color(string: String) -> Color {

pub fn replace_variable(str: String) -> String {
str.replace("%author%", "Charlotte Thomas")
.replace("%version%", "v3.0.0")
.replace("%version%", "v3.0.1")
.to_string()
}

Expand Down
5 changes: 3 additions & 2 deletions src/functions/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ pub fn apply_operator_reverse(
}

pub fn assign(s: Parameters, s2: Parameters) -> (String, Parameters) {
match s {
Identifier(s) => (s, s2),
match (s, s2.clone()) {
(Identifier(s), Identifier(s2)) if s == s2 => ("".to_string(), Identifier(s2)),
(Identifier(s), _) => (s, s2),
_ => ("".to_string(), s2),
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/interpreting/stdlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,16 @@ pub fn exec(
},
}
}
names.iter().zip(lst).for_each(|(name, param)| {
sram.insert(name.to_string(), param);
});
names
.iter()
.zip(lst)
.filter(|(name, param)| match param {
Parameters::Identifier(s) => s.as_str() != name.as_str(),
_ => true,
})
.for_each(|(name, param)| {
sram.insert(name.to_string(), param);
});
interpret(ast, &mut sram, &mut HashMap::new())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn handle_config(line: &str, config: Config) -> (String, Option<Config>) {
fn main() {
let mut args: Args = env::args();

let version: String = "v3.0.0".to_string();
let version: String = "v3.0.1".to_string();
if args.len() > 1 || !atty::is(Stream::Stdin) {
let mut a = vec![];

Expand Down

0 comments on commit feaa0a4

Please sign in to comment.