Map actual 0 hash to 42.

This commit is contained in:
Stephen Chung
2020-12-24 18:43:04 +08:00
parent 8506640073
commit 363085efc3
4 changed files with 38 additions and 29 deletions

View File

@@ -20,6 +20,7 @@ use crate::stdlib::{
string::ToString,
vec::Vec,
};
use crate::utils::combine_hashes;
use crate::{
calc_native_fn_hash, calc_script_fn_hash, Dynamic, Engine, EvalAltResult, FnPtr,
ImmutableString, Module, ParseErrorType, Position, Scope, StaticVec, INT,
@@ -1177,9 +1178,8 @@ impl Engine {
// and the actual list of argument `TypeId`'.s
let hash_fn_args =
calc_native_fn_hash(empty(), "", args.iter().map(|a| a.type_id())).unwrap();
// 3) The final hash is the XOR of the two hashes.
let hash_qualified_fn =
NonZeroU64::new(hash_script.get() ^ hash_fn_args.get()).unwrap();
// 3) The two hashes are combined.
let hash_qualified_fn = combine_hashes(hash_script, hash_fn_args);
module.get_qualified_fn(hash_qualified_fn)
}