proper position in recursion warning

This commit is contained in:
Irmen de Jong 2021-12-17 21:04:41 +01:00
parent e051e09c1d
commit 7bccfc0006

View File

@ -114,12 +114,12 @@ class CallGraph(private val program: Program) : IAstVisitor {
fun checkRecursiveCalls(errors: IErrorReporter) {
val cycles = recursionCycles()
if(cycles.any()) {
errors.warn("Program contains recursive subroutine calls. These only works in very specific limited scenarios!", Position.DUMMY)
errors.warn("Program contains recursive subroutine calls. These only works in very specific limited scenarios!", cycles[0][0].position)
val printed = mutableSetOf<Subroutine>()
for(chain in cycles) {
if(chain[0] !in printed) {
val chainStr = chain.joinToString(" <-- ") { "${it.name} at ${it.position}" }
errors.warn("Cycle in (a subroutine call in) $chainStr", Position.DUMMY)
errors.warn("Cycle in (a subroutine call in) $chainStr", chain[0].position)
printed.add(chain[0])
}
}