codekingpro/portable-devtools
114k
1// run2 3// Copyright 2023 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7// Some derived-type expressions require the compiler to synthesize8// function literals to plumb sub-dictionaries appropriately.9// However, when these expressions are inlined, we were constructing10// the function literal bodies with the inline-adjusted positions11// instead of the original (inline-free) positions, which could lead12// to infinite loops when unwinding the stack.13 14package main15 16import "runtime"17 18func assert[_ any]() {19 panic(0)20}21 22func Assert[To any]() func() {23 return assert[To]24}25 26type asserter[_ any] struct{}27 28func (asserter[_]) assert() {29 panic(0)30}31 32func AssertMV[To any]() func() {33 return asserter[To]{}.assert34}35 36func AssertME[To any]() func(asserter[To]) {37 return asserter[To].assert38}39 40var me = AssertME[string]()41 42var tests = []func(){43 Assert[int](),44 AssertMV[int](),45 func() { me(asserter[string]{}) },46}47 48func main() {49 for _, test := range tests {50 func() {51 defer func() {52 recover()53 54 // Check that we can unwind the stack without infinite looping.55 runtime.Caller(1000)56 }()57 test()58 }()59 }60}61 