-
-
Notifications
You must be signed in to change notification settings - Fork 782
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
Fixed export package-definitions not including cached modules #3669
base: main
Are you sure you want to change the base?
Changes from all commits
091794c
c72c488
4789222
09d3e9e
e67e3c5
11c1d18
88b5aff
cdb39b3
652e9cb
ce4c657
71f7037
3923c17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,10 @@ use crate::{ | |
fields::{FieldMap, FieldMapBuilder}, | ||
hydrator::Hydrator, | ||
prelude::*, | ||
AccessorsMap, Deprecation, ModuleInterface, PatternConstructor, RecordAccessor, Type, | ||
TypeConstructor, TypeValueConstructor, TypeValueConstructorField, TypeVariantConstructors, | ||
ValueConstructor, ValueConstructorVariant, Warning, | ||
AccessorsMap, Deprecation, FunctionArgument, ModuleInterface, PatternConstructor, | ||
RecordAccessor, Type, TypeAliasConstructor, TypeConstructor, TypeValueConstructor, | ||
TypeValueConstructorField, TypeVariantConstructors, ValueConstructor, | ||
ValueConstructorVariant, Warning, | ||
}, | ||
uid::UniqueIdGenerator, | ||
warning::TypeWarningEmitter, | ||
|
@@ -296,6 +297,7 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
let Environment { | ||
module_types: types, | ||
module_types_constructors: types_constructors, | ||
module_type_aliases: type_aliases, | ||
module_values: values, | ||
accessors, | ||
names: type_names, | ||
|
@@ -318,13 +320,15 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
} | ||
|
||
let module = ast::Module { | ||
documentation, | ||
documentation: documentation.clone(), | ||
name: self.module_name.clone(), | ||
definitions: typed_statements, | ||
type_info: ModuleInterface { | ||
name: self.module_name, | ||
documentation, | ||
types, | ||
types_value_constructors: types_constructors, | ||
type_aliases, | ||
values, | ||
accessors, | ||
origin: self.origin, | ||
|
@@ -523,7 +527,13 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
body, | ||
Some(prereg_return_type.clone()), | ||
)?; | ||
let args_types = args.iter().map(|a| a.type_.clone()).collect(); | ||
let args_types = args | ||
.iter() | ||
.map(|a| FunctionArgument { | ||
name: a.get_variable_name().cloned(), | ||
type_: a.type_.clone(), | ||
}) | ||
.collect(); | ||
let type_ = fn_(args_types, body.last().type_()); | ||
Ok(( | ||
type_, | ||
|
@@ -965,10 +975,18 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
} | ||
}; | ||
|
||
fields.push(TypeValueConstructorField { type_: t.clone() }); | ||
fields.push(TypeValueConstructorField { | ||
label: label | ||
.as_ref() | ||
.map_or(None, |(_, label)| Some(label.clone())), | ||
type_: t.clone(), | ||
}); | ||
|
||
// Register the type for this parameter | ||
args_types.push(t); | ||
args_types.push(FunctionArgument { | ||
name: None, | ||
type_: t, | ||
}); | ||
|
||
// Register the label for this parameter, if there is one | ||
if let Some((_, label)) = label { | ||
|
@@ -984,7 +1002,7 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
// Insert constructor function into module scope | ||
let type_ = match constructor.arguments.len() { | ||
0 => type_.clone(), | ||
_ => fn_(args_types.clone(), type_.clone()), | ||
_ => fn_(args_types, type_.clone()), | ||
}; | ||
let constructor_info = ValueConstructorVariant::Record { | ||
documentation: constructor | ||
|
@@ -1121,6 +1139,7 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
deprecation: deprecation.clone(), | ||
parameters, | ||
publicity, | ||
opaque: *opaque, | ||
type_, | ||
documentation: documentation.as_ref().map(|(_, doc)| doc.clone()), | ||
}, | ||
|
@@ -1177,13 +1196,16 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
// in some fashion. | ||
let mut hydrator = Hydrator::new(); | ||
let parameters = self.make_type_vars(args, &mut hydrator, environment); | ||
let tryblock = || { | ||
let mut tryblock = || { | ||
hydrator.disallow_new_type_variables(); | ||
let type_ = hydrator.type_from_ast(resolved_type, environment, &mut self.problems)?; | ||
let type_ref = | ||
hydrator.type_from_ast(resolved_type, environment, &mut self.problems)?; | ||
let type_ = type_ref.as_ref().clone(); | ||
let arity = parameters.len(); | ||
|
||
environment | ||
.names | ||
.type_in_scope(name.clone(), type_.as_ref()); | ||
.type_in_scope(name.clone(), type_ref.as_ref()); | ||
|
||
// Insert the alias so that it can be used by other code. | ||
environment.insert_type_constructor( | ||
|
@@ -1192,9 +1214,24 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
origin: *location, | ||
module: self.module_name.clone(), | ||
parameters, | ||
type_, | ||
type_: type_ref, | ||
deprecation: deprecation.clone(), | ||
publicity: *publicity, | ||
// TODO: Find if the type is opaque | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this mean? Is it unfinished? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot about this todo 😅. Is there a problem for the code to register the type alias as a non-opaque type, just for type analysis? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not aware of any problems, but I'm not sure what you mean here. |
||
opaque: false, | ||
documentation: documentation.as_ref().map(|(_, doc)| doc.clone()), | ||
}, | ||
)?; | ||
|
||
environment.insert_type_alias( | ||
name.clone(), | ||
TypeAliasConstructor { | ||
origin: *location, | ||
module: self.module_name.clone(), | ||
type_, | ||
arity, | ||
publicity: *publicity, | ||
deprecation: deprecation.clone(), | ||
documentation: documentation.as_ref().map(|(_, doc)| doc.clone()), | ||
}, | ||
)?; | ||
|
@@ -1294,7 +1331,14 @@ impl<'a, A> ModuleAnalyzer<'a, A> { | |
let arg_types = args | ||
.iter() | ||
.map(|arg| { | ||
hydrator.type_from_option_ast(&arg.annotation, environment, &mut self.problems) | ||
Ok(FunctionArgument { | ||
name: None, | ||
type_: hydrator.type_from_option_ast( | ||
&arg.annotation, | ||
environment, | ||
&mut self.problems, | ||
)?, | ||
}) | ||
}) | ||
.try_collect()?; | ||
let return_type = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function types don't contain names! Please remove this.
It would also be called a parameter. Things have parameters, and for those parameters they accept arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you mean that a parameter has a name/label, while an argument doesn't? In that case, I'd reuse the
TypeValueConstructorParameter
struct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair I wasn't happy with the approach I took 😅 . Tomorrow I'll try tackling this again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither has names at the type level, but parameters can have names locally within a definition.