@@ -1494,7 +1494,7 @@ impl TypeSignature {
1494
1494
type_args : & [ SymbolicExpression ] ,
1495
1495
accounting : & mut A ,
1496
1496
) -> Result < TypeSignature > {
1497
- let mapped_key_types = parse_name_type_pairs (
1497
+ let mapped_key_types = parse_name_type_pairs :: < _ , CheckErrors > (
1498
1498
epoch,
1499
1499
type_args,
1500
1500
SyntaxBindingErrorType :: TupleCons ,
@@ -1919,57 +1919,71 @@ use crate::vm::ClarityVersion;
1919
1919
/// Try to parse a list of (name_i, type_i) pairs into Vec<(ClarityName, TypeSignature)>.
1920
1920
/// On failure, return both the type-check error as well as the index of the symbolic expression which caused
1921
1921
/// the problem (for purposes of reporting the error).
1922
- pub fn parse_name_type_pairs < A : CostTracker > (
1922
+ pub fn parse_name_type_pairs < A : CostTracker , E > (
1923
1923
epoch : StacksEpochId ,
1924
1924
name_type_pairs : & [ SymbolicExpression ] ,
1925
1925
binding_error_type : SyntaxBindingErrorType ,
1926
1926
accounting : & mut A ,
1927
- ) -> std:: result:: Result < Vec < ( ClarityName , TypeSignature ) > , CheckErrors > {
1927
+ ) -> std:: result:: Result < Vec < ( ClarityName , TypeSignature ) > , E >
1928
+ where
1929
+ E : for < ' a > From < ( CheckErrors , & ' a SymbolicExpression ) > ,
1930
+ {
1928
1931
// this is a pretty deep nesting here, but what we're trying to do is pick out the values of
1929
1932
// the form:
1930
1933
// ((name1 type1) (name2 type2) (name3 type3) ...)
1931
1934
// which is a list of 2-length lists of atoms.
1932
1935
use crate :: vm:: representations:: SymbolicExpressionType :: List ;
1933
1936
1934
1937
// step 1: parse it into a vec of symbolicexpression pairs.
1935
- let as_pairs: std:: result:: Result < Vec < _ > , CheckErrors > = name_type_pairs
1938
+ let as_pairs: std:: result:: Result < Vec < _ > , ( CheckErrors , & SymbolicExpression ) > = name_type_pairs
1936
1939
. iter ( )
1937
1940
. enumerate ( )
1938
1941
. map ( |( i, key_type_pair) | {
1939
1942
if let List ( ref as_vec) = key_type_pair. expr {
1940
1943
if as_vec. len ( ) != 2 {
1941
- Err ( CheckErrors :: BadSyntaxBinding (
1942
- SyntaxBindingError :: InvalidLength ( binding_error_type, i) ,
1944
+ Err ( (
1945
+ CheckErrors :: BadSyntaxBinding ( SyntaxBindingError :: InvalidLength (
1946
+ binding_error_type,
1947
+ i,
1948
+ ) ) ,
1949
+ key_type_pair,
1943
1950
) )
1944
1951
} else {
1945
1952
Ok ( ( & as_vec[ 0 ] , & as_vec[ 1 ] ) )
1946
1953
}
1947
1954
} else {
1948
- Err ( SyntaxBindingError :: NotList ( binding_error_type, i) . into ( ) )
1955
+ Err ( (
1956
+ SyntaxBindingError :: NotList ( binding_error_type, i) . into ( ) ,
1957
+ key_type_pair,
1958
+ ) )
1949
1959
}
1950
1960
} )
1951
1961
. collect ( ) ;
1952
1962
1953
1963
// step 2: turn into a vec of (name, typesignature) pairs.
1954
- let key_types: std:: result:: Result < Vec < _ > , CheckErrors > = ( as_pairs?)
1964
+ let key_types: std:: result:: Result < Vec < _ > , ( CheckErrors , & SymbolicExpression ) > = ( as_pairs?)
1955
1965
. iter ( )
1956
1966
. enumerate ( )
1957
1967
. map ( |( i, ( name_symbol, type_symbol) ) | {
1958
1968
let name = name_symbol
1959
1969
. match_atom ( )
1960
1970
. ok_or_else ( || {
1961
- CheckErrors :: BadSyntaxBinding ( SyntaxBindingError :: NotAtom (
1962
- binding_error_type,
1963
- i,
1964
- ) )
1971
+ (
1972
+ CheckErrors :: BadSyntaxBinding ( SyntaxBindingError :: NotAtom (
1973
+ binding_error_type,
1974
+ i,
1975
+ ) ) ,
1976
+ * name_symbol,
1977
+ )
1965
1978
} ) ?
1966
1979
. clone ( ) ;
1967
- let type_info = TypeSignature :: parse_type_repr ( epoch, type_symbol, accounting) ?;
1980
+ let type_info = TypeSignature :: parse_type_repr ( epoch, type_symbol, accounting)
1981
+ . map_err ( |e| ( e, * type_symbol) ) ?;
1968
1982
Ok ( ( name, type_info) )
1969
1983
} )
1970
1984
. collect ( ) ;
1971
1985
1972
- key_types
1986
+ Ok ( key_types? )
1973
1987
}
1974
1988
1975
1989
impl fmt:: Display for TupleTypeSignature {
0 commit comments