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

Type Alias can start with a capital letter accidentally #564

Closed
pocke opened this issue Jan 2, 2021 · 0 comments · Fixed by #565
Closed

Type Alias can start with a capital letter accidentally #564

pocke opened this issue Jan 2, 2021 · 0 comments · Fixed by #565
Assignees
Labels
bug Something isn't working

Comments

@pocke
Copy link
Member

pocke commented Jan 2, 2021

Problem

Type Alias should start with a small letter.
But it can start with a capital letter accidentally in the syntax.

# test.rbs

type T = String

class C
  def m: () -> T
end
$ rbs parse test.rbs
$ echo $?
0

$ rbs -I . validate --silent
/path/to/rbs-1.0.0/lib/rbs/errors.rb:96:in `check!': test.rbs:4:15...4:16: Could not find ::T (RBS::NoTypeFoundError)
	from /path/to/rbs-1.0.0/lib/rbs/variance_calculator.rb:114:in `type'
	from /path/to/rbs-1.0.0/lib/rbs/variance_calculator.rb:83:in `in_method_type'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:523:in `block (2 levels) in validate_type_params'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:522:in `each'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:522:in `block in validate_type_params'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder/method_builder.rb:48:in `block in each'
	from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder/method_builder.rb:65:in `each_value'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder/method_builder.rb:65:in `tsort_each_node'
	from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/tsort.rb:347:in `call'
	from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
	from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/tsort.rb:316:in `each_strongly_connected_component'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder/method_builder.rb:43:in `each'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:485:in `validate_type_params'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:150:in `block (2 levels) in build_instance'
	from <internal:kernel>:90:in `tap'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:146:in `block in build_instance'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:765:in `try_cache'
	from /path/to/rbs-1.0.0/lib/rbs/definition_builder.rb:135:in `build_instance'
	from /path/to/rbs-1.0.0/lib/rbs/cli.rb:423:in `block in run_validate'
	from /path/to/rbs-1.0.0/lib/rbs/cli.rb:421:in `each_key'
	from /path/to/rbs-1.0.0/lib/rbs/cli.rb:421:in `run_validate'
	from /path/to/rbs-1.0.0/lib/rbs/cli.rb:113:in `run'
	from /path/to/rbs-1.0.0/exe/rbs:7:in `<top (required)>'
	from /home/pocke/.rbenv/versions/trunk/bin/rbs:23:in `load'
	from /home/pocke/.rbenv/versions/trunk/bin/rbs:23:in `<main>'

Expected Behavior

I think it should cause a syntax error.
The type alias T can't be referred because a name that starts with a capital letter is a class or module. So it is confusing if it doesn't cause a syntax error.

@pocke pocke added the bug Something isn't working label Jan 2, 2021
@pocke pocke self-assigned this Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant