grain
grain copied to clipboard
Grain seems to treat a type as a different type when the module "as" functionality is used when importing its module
The following code (also implemented in this attachment: bad_module_example.zip) exhibits the following behavior:
grain main.gr
File "main.gr", line 9, characters 10-20:
Error: This expression has type DifferentName.Type
but an expression was expected of type TypeProvider.Type
TypeProvider::Type is abstract because no corresponding cmi file was found in path.
I would expect DifferentName.Type and TypeProvider.Type would be treated as the same type, as DifferentName.Type is just an alias/renaming of TypeProvider.Type.
There are similarities between this issue and https://github.com/grain-lang/grain/issues/1758.
main.gr
module Main
from "./type_provider.gr" include TypeProvider as DifferentName
use DifferentName.{ type Type }
from "./function_provider.gr" include FunctionProvider
use FunctionProvider.{ function }
function( {field: 5} )
type_provider.gr
module TypeProvider
provide record Type {
field: Number
}
function_provider.gr
module FunctionProvider
from "./type_provider.gr" include TypeProvider
use TypeProvider.{ type Type }
provide let function = (t: Type) => {
void
}