Skip to content

Conversation

@Premwoik
Copy link
Collaborator

@Premwoik Premwoik commented Nov 9, 2021

This PR adds the following features:

  • better line specification in @spec (could be useless, so maybe should be commented),
  • code refactoring for better readability,
  • type pretty printer in Elixir.

This commit aimed to specify a line in the undefined remote type error message.
Unfortunately, the missing line was not the Elixir thing because Gradualizer
cleans the location info on purpose. Well, but the mapper may be useful
in the future, so why not push it.
- Add spec mapper
- Test spec mapper
Included changes:
- Make code cleaner and better organized.
- Extract functions handling tokens to new Tokens module.
- Extract types to new Types module.
- Rename SpecifyErlAst to AstSpecifier module.
- [test] Extract helper functions to new test helper module.
- [test] Add test module for tokens and move tokens tests there.
@Premwoik Premwoik marked this pull request as ready for review November 15, 2021 10:34
@Premwoik Premwoik requested a review from erszcz November 15, 2021 10:34
errors = type_check_file(ast, opts)

for e <- errors do
:io.put_chars(e)
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't assert anything in this test, do we? I think it's fine to have one or two tests that just use the expected literal binaries to assert if the formatting works as expected. Obviously, we won't do it for all possible error types, but a few are OK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this test case needs to assert something in the future. I used it only to display some results and it is set to be skipped. Should I try to provide some real tests in this PR or do it in a new one?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be nice to have in this PR 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I will try to provide some tests then :)

Copy link
Collaborator Author

@Premwoik Premwoik Nov 17, 2021

Choose a reason for hiding this comment

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

I added tests for the cases defined in the test/examples/type/wrong_ret.ex 😃 I only check there if the error message contains the correct value. I don't want to compare the full message because the message could change in near future. Also, these checks should be later replaced with something more precise.

@erszcz
Copy link
Contributor

erszcz commented Nov 15, 2021

That's great!
I left a few comments / suggestions inline.

I think it would be good to start with a GitHub Actions workflow to have some CI, so let's wait with merging this PR until we have that. EDIT: well, my bad. Obviously, we have some tests in CI already 😅

Co-authored-by: Radek Szymczyszyn <radoslaw.szymczyszyn@erlang-solutions.com>
erszcz and others added 3 commits November 16, 2021 15:59
- Add top-level type for a get_conditional return.
- Rename flat_tokens to flatten_tokens.
@Premwoik Premwoik requested a review from kmakiela November 18, 2021 11:34
@erszcz erszcz merged commit dd1467b into main Nov 29, 2021
@erszcz erszcz deleted the new-features-from-old-repo branch November 29, 2021 15:51
@Premwoik Premwoik mentioned this pull request Feb 4, 2022
4 tasks
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.

3 participants