File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -394,3 +394,23 @@ fun main() {
394394}
395395------------------------------------------------------------------------
396396ok
397+
398+ ========================================================================
399+ Cyclic dependency with Cell in struct
400+ ========================================================================
401+ struct SwapStep {
402+ pool: address
403+ minAmountOut: coins
404+ nextStep: Cell<SwapStep>?
405+ }
406+
407+ fun main() {
408+ val foo = SwapStep{};
409+ //! ^ SwapStep
410+ val step = foo.nextStep!
411+ //! ^ Cell<SwapStep>
412+ val loadedStep = foo.nextStep!.load()
413+ //! ^ SwapStep
414+ }
415+ ------------------------------------------------------------------------
416+ ok
Original file line number Diff line number Diff line change @@ -670,11 +670,16 @@ export class TypeInferer {
670670
671671 private inferTypeFromResolved ( resolved : NamedNode ) : Ty | null {
672672 if ( resolved instanceof Struct ) {
673- const baseTy = new StructTy (
674- resolved . fields ( ) . map ( it => this . inferType ( it . typeNode ( ) ) ?? UnknownTy . UNKNOWN ) ,
675- resolved . name ( ) ,
676- resolved ,
677- )
673+ const fieldTypes = resolved . fields ( ) . map ( it => {
674+ try {
675+ return this . inferType ( it . typeNode ( ) ) ?? UnknownTy . UNKNOWN
676+ } catch {
677+ // cyclic dependency
678+ return UnknownTy . UNKNOWN
679+ }
680+ } )
681+
682+ const baseTy = new StructTy ( fieldTypes , resolved . name ( ) , resolved )
678683
679684 const typeParameters = resolved . typeParameters ( )
680685 if ( typeParameters . length > 0 ) {
You can’t perform that action at this time.
0 commit comments