Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack-overflow bug: A nested record can't be it's interface parent #860

Closed
Andre-LA opened this issue Nov 23, 2024 · 6 comments
Closed

stack-overflow bug: A nested record can't be it's interface parent #860

Andre-LA opened this issue Nov 23, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Andre-LA
Copy link

Andre-LA commented Nov 23, 2024

The code below crashes the compiler on a stack overflow on the close_nested_records function:

local interface X
   record A is X
   end
end

Teal version: 0.24.1

@hishamhm hishamhm added the bug Something isn't working label Dec 6, 2024
@mtdowling
Copy link

This is somewhat related to #870. We might want to just forbid nesting records in interfaces since interfaces don't generate code.

@hishamhm
Copy link
Member

The bug also happened with nested interfaces. I made a small tweak so that it doesn't crash anymore, but I'm wondering if other weird behaviors might come up from it.

Is there a real-life use-case for an inner interface that extends its outer interface? I'm afraid such circular types will start causing other problems...

@Andre-LA
Copy link
Author

Is there a real-life use-case for an inner interface that extends its outer interface? I'm afraid such circular types will start causing other problems

Maybe due to exporting to other modules?

interA.tl:

local interface A
	a: integer

	interface B is A
		b: string
	end
end

return A

test.tl:

local type A = require 'interA'

local x: A.B = {
	a = 10,
	b = 'hello'
}

print(x.a, x.b) --> 10	hello

@hishamhm
Copy link
Member

@Andre-LA this still looks like a "synthetic" example, I'm afraid...

@mtdowling
Copy link

FWIW, you can nest interfaces like this is Java. It’s solely used for grouping.

@hishamhm
Copy link
Member

hishamhm commented Jan 11, 2025

Nesting interfaces is supported. Having the nested one its own parent (producing a circular nesting once the inner interface is resolved) is the thing I'm finding odd here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants