@@ -5596,8 +5596,11 @@ export class Compiler extends DiagnosticEmitter {
55965596 }
55975597 return this . module . unreachable ( ) ;
55985598 }
5599- assert ( indexedSet . signature . parameterTypes . length == 2 ) ; // parser must guarantee this
5600- targetType = indexedSet . signature . parameterTypes [ 1 ] ; // 2nd parameter is the element
5599+ let parameterTypes = indexedSet . signature . parameterTypes ;
5600+
5601+ assert ( parameterTypes . length == 2 ) ; // parser must guarantee this
5602+ targetType = parameterTypes [ 1 ] ; // 2nd parameter is the element
5603+
56015604 if ( indexedSet . hasDecorator ( DecoratorFlags . UNSAFE ) ) this . checkUnsafe ( expression ) ;
56025605 if ( ! isUnchecked && this . options . pedantic ) {
56035606 this . pedantic (
@@ -5788,7 +5791,19 @@ export class Compiler extends DiagnosticEmitter {
57885791 thisType ,
57895792 Constraints . CONV_IMPLICIT | Constraints . IS_THIS
57905793 ) ;
5791- let elementExpr = this . compileExpression ( assert ( indexExpression ) , Type . i32 , Constraints . CONV_IMPLICIT ) ;
5794+ let setterIndexType = setterInstance . signature . parameterTypes [ 0 ] ;
5795+ let getterIndexType = getterInstance . signature . parameterTypes [ 0 ] ;
5796+ if ( ! setterIndexType . equals ( getterIndexType ) ) {
5797+ this . errorRelated (
5798+ DiagnosticCode . Index_signature_accessors_in_type_0_differ_in_types ,
5799+ getterInstance . identifierAndSignatureRange ,
5800+ setterInstance . identifierAndSignatureRange ,
5801+ classInstance . internalName ,
5802+ ) ;
5803+ this . currentType = tee ? getterInstance . signature . returnType : Type . void ;
5804+ return module . unreachable ( ) ;
5805+ }
5806+ let elementExpr = this . compileExpression ( assert ( indexExpression ) , setterIndexType , Constraints . CONV_IMPLICIT ) ;
57925807 let elementType = this . currentType ;
57935808 if ( tee ) {
57945809 let tempTarget = flow . getTempLocal ( thisType ) ;
0 commit comments