Closed fknfilewalker closed 1 month ago
It is not valid to define a typealias
inside an interface
. If you wish to define a requirement that all implemnetations need to provide, you are probably looking for associatedtype
.
For example:
interface IFoo
{
associatedtype Scalar : __BuiltinArithmeticType;
}
struct Bar : IFoo
{
typealias Scalar = float;
}
We need to not treat a typealias
inside an interface as a requirement for subtypes. Instead it should just mean a type alias in the scope of that interface decl.
Or perhaps we should just disallow defining a typealias
inside an interface.
Thank you for the help, this works perfectly
We need to not treat a
typealias
inside an interface as a requirement for subtypes. Instead it should just mean a type alias in the scope of that interface decl. This would be more in line with the expected behavior I guess
Static const vars can easily be defined in interfaces and then set in the implementation
for typealias this does not work and the error messages are not clear to me e.g., this for instance displays an error in struct Bar:
member 'Scalar' does not match interface requirement.(38105)
see interface requirement declaration of 'Scalar'
if I don't set anything in Bar I get
type 'Bar' does not provide required interface member 'Scalar'(38100)
see declaration of 'Scalar'
Even setting Scalar to void in Bar does not work?
Slang version 2024.1.20