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

Introduce Identifier remove a lot of Strings #192

Merged
merged 4 commits into from
Mar 26, 2019
Merged

Conversation

johnynek
Copy link
Owner

This was not a fun refactor, but it was real techdebt.

Previously, we were using String in many cases for identifiers. It is hard to refactor such code because we don't know which of those are referring to binding names, type names or Constructors.

This introduces Identifier which is intended to keep track of this and be clear that we are never recreating those strings after parsing.

This is related to #12 and #70 since both of those will need to touch how identifiers are delt with.

@codecov-io
Copy link

codecov-io commented Mar 25, 2019

Codecov Report

Merging #192 into master will increase coverage by 0.06%.
The diff coverage is 92.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
+ Coverage   83.16%   83.23%   +0.06%     
==========================================
  Files          49       50       +1     
  Lines        3237     3256      +19     
  Branches      138      136       -2     
==========================================
+ Hits         2692     2710      +18     
- Misses        545      546       +1
Impacted Files Coverage Δ
.../src/main/scala/org/bykn/bosatsu/rankn/Infer.scala 86.37% <ø> (ø) ⬆️
.../main/scala/org/bykn/bosatsu/VarianceFormula.scala 94.11% <ø> (-0.05%) ⬇️
...n/scala/org/bykn/bosatsu/rankn/ParsedTypeEnv.scala 100% <ø> (ø) ⬆️
...e/src/main/scala/org/bykn/bosatsu/PackageMap.scala 50.37% <0%> (-0.38%) ⬇️
core/src/main/scala/org/bykn/bosatsu/Package.scala 98.18% <100%> (ø) ⬆️
...ore/src/main/scala/org/bykn/bosatsu/Referant.scala 100% <100%> (ø) ⬆️
core/src/main/scala/org/bykn/bosatsu/Predef.scala 92.8% <100%> (+0.05%) ⬆️
core/src/main/scala/org/bykn/bosatsu/Pattern.scala 96.46% <100%> (+0.03%) ⬆️
...in/scala/org/bykn/bosatsu/TypeRecursionCheck.scala 97.91% <100%> (ø) ⬆️
.../src/main/scala/org/bykn/bosatsu/Declaration.scala 98.19% <100%> (+0.43%) ⬆️
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 390be5e...fa8682a. Read the comment docs.

Referant.importedTypes(imps)

val resolveImportedCons: Map[String, (PackageName, ConstructorName)] =
val resolveImportedCons: Map[Identifier, (PackageName, Constructor)] =
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the key here should be Constructor.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't easy actually, imports don't know currently if the are bindable or constructors. I'm going to leave it as Identifier, which is at least an improvement.

@@ -151,7 +153,7 @@ object DefRecursionCheck {
*/
def checkForIllegalBinds[A](
state: State,
bs: Iterable[String],
bs: Iterable[Identifier.Bindable],
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bindable has been imported.

@johnynek johnynek merged commit b555da1 into master Mar 26, 2019
@johnynek johnynek deleted the oscar/add_identifier branch March 26, 2019 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants