Fix type check error
This commit is contained in:
parent
2bcb5f59f7
commit
a27b33dd36
@ -10,12 +10,6 @@ is_ready_to_solve = (fn cards <map>) <bool> {
|
|||||||
&& ((length cards:weapons) == 1)
|
&& ((length cards:weapons) == 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
take_turn = (fn cards <map>, opponent_card <str>, current_room <str>) <map> {
|
|
||||||
cards = (remove_card cards opponent_card)
|
|
||||||
cards = (make_guess cards current_room)
|
|
||||||
cards
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_card = (fn cards <map>, opponent_card <str>) <map> {
|
remove_card = (fn cards <map>, opponent_card <str>) <map> {
|
||||||
cards:rooms -= opponent_card
|
cards:rooms -= opponent_card
|
||||||
cards:suspects -= opponent_card
|
cards:suspects -= opponent_card
|
||||||
@ -44,6 +38,12 @@ make_guess = (fn cards <map>, current_room <str>) <map> {
|
|||||||
cards
|
cards
|
||||||
}
|
}
|
||||||
|
|
||||||
|
take_turn = (fn cards <map>, opponent_card <str>, current_room <str>) <map> {
|
||||||
|
cards = (remove_card cards opponent_card)
|
||||||
|
cards = (make_guess cards current_room)
|
||||||
|
cards
|
||||||
|
}
|
||||||
|
|
||||||
all_cards
|
all_cards
|
||||||
-> (take_turn 'Rope' 'Kitchen')
|
-> (take_turn 'Rope' 'Kitchen')
|
||||||
-> (take_turn 'Library' 'Kitchen')
|
-> (take_turn 'Library' 'Kitchen')
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tree_sitter::Node;
|
use tree_sitter::Node;
|
||||||
|
|
||||||
use crate::{AbstractTree, Error, Map, Result, Type, Value, ValueNode, BUILT_IN_FUNCTIONS};
|
use crate::{
|
||||||
|
AbstractTree, Error, Expression, Map, Result, Type, Value, ValueNode, BUILT_IN_FUNCTIONS,
|
||||||
use super::expression::Expression;
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
pub struct FunctionCall {
|
pub struct FunctionCall {
|
||||||
@ -144,7 +144,19 @@ impl AbstractTree for FunctionCall {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
identifier.expected_type(context)
|
let identifier_type = identifier.expected_type(context)?;
|
||||||
|
|
||||||
|
println!("{identifier_type:?}");
|
||||||
|
|
||||||
|
if let Type::Function {
|
||||||
|
parameter_types: _,
|
||||||
|
return_type,
|
||||||
|
} = &identifier_type
|
||||||
|
{
|
||||||
|
Ok(*return_type.clone())
|
||||||
|
} else {
|
||||||
|
Ok(identifier_type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Expression::Index(index) => index.expected_type(context),
|
Expression::Index(index) => index.expected_type(context),
|
||||||
Expression::Math(math) => math.expected_type(context),
|
Expression::Math(math) => math.expected_type(context),
|
||||||
|
Loading…
Reference in New Issue
Block a user