steep 1.6.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +49 -0
- data/README.md +18 -0
- data/Rakefile +5 -0
- data/bin/output_test.rb +1 -0
- data/doc/narrowing.md +195 -0
- data/doc/shape.md +194 -0
- data/guides/src/gem-rbs-collection/gem-rbs-collection.md +7 -24
- data/guides/src/getting-started/getting-started.md +10 -11
- data/lib/steep/ast/ignore.rb +148 -0
- data/lib/steep/ast/types/factory.rb +27 -18
- data/lib/steep/ast/types/helper.rb +4 -0
- data/lib/steep/ast/types/intersection.rb +7 -0
- data/lib/steep/ast/types/proc.rb +14 -9
- data/lib/steep/ast/types/record.rb +7 -0
- data/lib/steep/ast/types/tuple.rb +7 -0
- data/lib/steep/ast/types/union.rb +7 -0
- data/lib/steep/cli.rb +6 -1
- data/lib/steep/diagnostic/ruby.rb +16 -0
- data/lib/steep/drivers/stats.rb +2 -2
- data/lib/steep/drivers/utils/driver_helper.rb +22 -11
- data/lib/steep/drivers/validate.rb +4 -2
- data/lib/steep/expectations.rb +2 -2
- data/lib/steep/interface/block.rb +1 -1
- data/lib/steep/interface/builder.rb +342 -358
- data/lib/steep/interface/function.rb +82 -11
- data/lib/steep/interface/method_type.rb +18 -10
- data/lib/steep/interface/shape.rb +69 -18
- data/lib/steep/interface/substitution.rb +4 -0
- data/lib/steep/node_helper.rb +30 -1
- data/lib/steep/project/dsl.rb +18 -21
- data/lib/steep/project/options.rb +39 -2
- data/lib/steep/project/pattern.rb +1 -2
- data/lib/steep/project.rb +11 -7
- data/lib/steep/rake_task.rb +132 -0
- data/lib/steep/server/change_buffer.rb +2 -2
- data/lib/steep/server/interaction_worker.rb +67 -11
- data/lib/steep/server/lsp_formatter.rb +2 -0
- data/lib/steep/server/worker_process.rb +3 -1
- data/lib/steep/services/completion_provider.rb +59 -26
- data/lib/steep/services/file_loader.rb +15 -19
- data/lib/steep/services/signature_help_provider.rb +37 -35
- data/lib/steep/services/type_check_service.rb +36 -8
- data/lib/steep/signature/validator.rb +185 -133
- data/lib/steep/source/ignore_ranges.rb +69 -0
- data/lib/steep/source.rb +10 -4
- data/lib/steep/subtyping/check.rb +50 -43
- data/lib/steep/subtyping/result.rb +6 -0
- data/lib/steep/subtyping/variable_variance.rb +3 -3
- data/lib/steep/test.rb +9 -0
- data/lib/steep/type_construction.rb +205 -309
- data/lib/steep/type_inference/block_params.rb +12 -4
- data/lib/steep/type_inference/case_when.rb +301 -0
- data/lib/steep/type_inference/context.rb +1 -1
- data/lib/steep/type_inference/logic_type_interpreter.rb +3 -2
- data/lib/steep/type_inference/method_params.rb +16 -0
- data/lib/steep/type_inference/send_args.rb +5 -2
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +25 -8
- data/steep.gemspec +5 -2
- metadata +12 -396
- data/.github/dependabot.yml +0 -22
- data/.github/workflows/ruby-windows.yml +0 -34
- data/.github/workflows/ruby.yml +0 -33
- data/.vscode/steep-shared.code-snippets +0 -41
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -104
- data/Gemfile.steep +0 -0
- data/gemfile_steep/Gemfile +0 -3
- data/gemfile_steep/Gemfile.lock +0 -64
- data/rbs_collection.steep.lock.yaml +0 -106
- data/rbs_collection.steep.yaml +0 -23
- data/sig/shims/bundler.rbs +0 -3
- data/sig/shims/concurrent-ruby.rbs +0 -39
- data/sig/shims/exception.rbs +0 -4
- data/sig/shims/language-server_protocol.rbs +0 -450
- data/sig/shims/parser/comment.rbs +0 -33
- data/sig/shims/parser/nodes.rbs +0 -252
- data/sig/shims/parser/source/map.rbs +0 -146
- data/sig/shims/parser/source/range.rbs +0 -237
- data/sig/shims/parser.rbs +0 -59
- data/sig/shims/string.rbs +0 -4
- data/sig/shims/tagged_logging.rbs +0 -6
- data/sig/steep/annotation_parser.rbs +0 -60
- data/sig/steep/ast/annotation/collection.rbs +0 -78
- data/sig/steep/ast/annotation.rbs +0 -121
- data/sig/steep/ast/builtin.rbs +0 -69
- data/sig/steep/ast/node/type_application.rbs +0 -31
- data/sig/steep/ast/node/type_assertion.rbs +0 -32
- data/sig/steep/ast/types/any.rbs +0 -29
- data/sig/steep/ast/types/boolean.rbs +0 -31
- data/sig/steep/ast/types/bot.rbs +0 -29
- data/sig/steep/ast/types/class.rbs +0 -33
- data/sig/steep/ast/types/factory.rbs +0 -110
- data/sig/steep/ast/types/helper.rbs +0 -22
- data/sig/steep/ast/types/instance.rbs +0 -33
- data/sig/steep/ast/types/intersection.rbs +0 -38
- data/sig/steep/ast/types/literal.rbs +0 -35
- data/sig/steep/ast/types/logic.rbs +0 -83
- data/sig/steep/ast/types/name.rbs +0 -80
- data/sig/steep/ast/types/nil.rbs +0 -31
- data/sig/steep/ast/types/proc.rbs +0 -53
- data/sig/steep/ast/types/record.rbs +0 -37
- data/sig/steep/ast/types/self.rbs +0 -33
- data/sig/steep/ast/types/top.rbs +0 -29
- data/sig/steep/ast/types/tuple.rbs +0 -35
- data/sig/steep/ast/types/union.rbs +0 -38
- data/sig/steep/ast/types/var.rbs +0 -42
- data/sig/steep/ast/types/void.rbs +0 -29
- data/sig/steep/ast/types.rbs +0 -16
- data/sig/steep/cli.rbs +0 -55
- data/sig/steep/diagnostic/deprecated/else_on_exhaustive_case.rbs +0 -13
- data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +0 -15
- data/sig/steep/diagnostic/helper.rbs +0 -15
- data/sig/steep/diagnostic/lsp_formatter.rbs +0 -36
- data/sig/steep/diagnostic/ruby.rbs +0 -695
- data/sig/steep/diagnostic/signature.rbs +0 -252
- data/sig/steep/drivers/annotations.rbs +0 -17
- data/sig/steep/drivers/check.rbs +0 -33
- data/sig/steep/drivers/checkfile.rbs +0 -27
- data/sig/steep/drivers/diagnostic_printer.rbs +0 -25
- data/sig/steep/drivers/init.rbs +0 -19
- data/sig/steep/drivers/langserver.rbs +0 -36
- data/sig/steep/drivers/print_project.rbs +0 -15
- data/sig/steep/drivers/stats.rbs +0 -47
- data/sig/steep/drivers/utils/driver_helper.rbs +0 -25
- data/sig/steep/drivers/utils/jobs_option.rbs +0 -19
- data/sig/steep/drivers/validate.rbs +0 -15
- data/sig/steep/drivers/vendor.rbs +0 -19
- data/sig/steep/drivers/watch.rbs +0 -27
- data/sig/steep/drivers/worker.rbs +0 -29
- data/sig/steep/equatable.rbs +0 -11
- data/sig/steep/expectations.rbs +0 -72
- data/sig/steep/index/rbs_index.rbs +0 -141
- data/sig/steep/index/signature_symbol_provider.rbs +0 -41
- data/sig/steep/index/source_index.rbs +0 -63
- data/sig/steep/interface/block.rbs +0 -41
- data/sig/steep/interface/builder.rbs +0 -166
- data/sig/steep/interface/function.rbs +0 -265
- data/sig/steep/interface/method_type.rbs +0 -105
- data/sig/steep/interface/shape.rbs +0 -61
- data/sig/steep/interface/substitution.rbs +0 -49
- data/sig/steep/interface/type_param.rbs +0 -43
- data/sig/steep/method_name.rbs +0 -30
- data/sig/steep/module_helper.rbs +0 -16
- data/sig/steep/node_helper.rbs +0 -78
- data/sig/steep/path_helper.rbs +0 -15
- data/sig/steep/project/dsl.rbs +0 -104
- data/sig/steep/project/options.rbs +0 -27
- data/sig/steep/project/pattern.rbs +0 -47
- data/sig/steep/project/target.rbs +0 -25
- data/sig/steep/project.rbs +0 -26
- data/sig/steep/range_extension.rbs +0 -7
- data/sig/steep/server/base_worker.rbs +0 -49
- data/sig/steep/server/change_buffer.rbs +0 -36
- data/sig/steep/server/delay_queue.rbs +0 -37
- data/sig/steep/server/interaction_worker.rbs +0 -80
- data/sig/steep/server/lsp_formatter.rbs +0 -63
- data/sig/steep/server/master.rbs +0 -299
- data/sig/steep/server/type_check_worker.rbs +0 -141
- data/sig/steep/server/worker_process.rbs +0 -97
- data/sig/steep/services/completion_provider.rbs +0 -251
- data/sig/steep/services/content_change.rbs +0 -37
- data/sig/steep/services/file_loader.rbs +0 -21
- data/sig/steep/services/goto_service.rbs +0 -106
- data/sig/steep/services/hover_provider/rbs.rbs +0 -47
- data/sig/steep/services/hover_provider/ruby.rbs +0 -127
- data/sig/steep/services/hover_provider/singleton_methods.rbs +0 -11
- data/sig/steep/services/path_assignment.rbs +0 -21
- data/sig/steep/services/signature_help_provider.rbs +0 -49
- data/sig/steep/services/signature_service.rbs +0 -156
- data/sig/steep/services/stats_calculator.rbs +0 -41
- data/sig/steep/services/type_check_service.rbs +0 -107
- data/sig/steep/services/type_name_completion.rbs +0 -135
- data/sig/steep/signature/validator.rbs +0 -85
- data/sig/steep/source.rbs +0 -102
- data/sig/steep/subtyping/cache.rbs +0 -17
- data/sig/steep/subtyping/check.rbs +0 -129
- data/sig/steep/subtyping/constraints.rbs +0 -111
- data/sig/steep/subtyping/relation.rbs +0 -63
- data/sig/steep/subtyping/result.rbs +0 -175
- data/sig/steep/subtyping/variable_variance.rbs +0 -25
- data/sig/steep/thread_waiter.rbs +0 -13
- data/sig/steep/type_construction.rbs +0 -567
- data/sig/steep/type_inference/block_params.rbs +0 -170
- data/sig/steep/type_inference/constant_env.rbs +0 -29
- data/sig/steep/type_inference/context.rbs +0 -214
- data/sig/steep/type_inference/context_array.rbs +0 -38
- data/sig/steep/type_inference/logic_type_interpreter.rbs +0 -108
- data/sig/steep/type_inference/method_call.rbs +0 -124
- data/sig/steep/type_inference/method_params.rbs +0 -127
- data/sig/steep/type_inference/multiple_assignment.rbs +0 -76
- data/sig/steep/type_inference/send_args.rbs +0 -243
- data/sig/steep/type_inference/type_env.rbs +0 -160
- data/sig/steep/type_inference/type_env_builder.rbs +0 -81
- data/sig/steep/typing.rbs +0 -75
- data/sig/steep.rbs +0 -36
- data/smoke/alias/Steepfile +0 -6
- data/smoke/alias/a.rb +0 -16
- data/smoke/alias/a.rbs +0 -10
- data/smoke/alias/b.rb +0 -6
- data/smoke/alias/c.rb +0 -8
- data/smoke/alias/test_expectations.yml +0 -96
- data/smoke/and/Steepfile +0 -6
- data/smoke/and/a.rb +0 -8
- data/smoke/and/test_expectations.yml +0 -29
- data/smoke/array/Steepfile +0 -6
- data/smoke/array/a.rb +0 -18
- data/smoke/array/b.rb +0 -12
- data/smoke/array/c.rb +0 -6
- data/smoke/array/test_expectations.yml +0 -103
- data/smoke/block/Steepfile +0 -6
- data/smoke/block/a.rb +0 -10
- data/smoke/block/a.rbs +0 -6
- data/smoke/block/b.rb +0 -13
- data/smoke/block/c.rb +0 -9
- data/smoke/block/c.rbs +0 -3
- data/smoke/block/d.rb +0 -11
- data/smoke/block/e.rb +0 -12
- data/smoke/block/e.rbs +0 -4
- data/smoke/block/test_expectations.yml +0 -133
- data/smoke/case/Steepfile +0 -6
- data/smoke/case/a.rb +0 -18
- data/smoke/case/test_expectations.yml +0 -47
- data/smoke/class/Steepfile +0 -6
- data/smoke/class/a.rb +0 -25
- data/smoke/class/a.rbs +0 -23
- data/smoke/class/b.rb +0 -5
- data/smoke/class/c.rb +0 -9
- data/smoke/class/f.rb +0 -10
- data/smoke/class/g.rb +0 -6
- data/smoke/class/h.rb +0 -19
- data/smoke/class/h.rbs +0 -6
- data/smoke/class/i.rb +0 -14
- data/smoke/class/i.rbs +0 -9
- data/smoke/class/test_expectations.yml +0 -117
- data/smoke/compact/Steepfile +0 -6
- data/smoke/compact/a.rb +0 -2
- data/smoke/compact/a.rbs +0 -5
- data/smoke/compact/b.rb +0 -2
- data/smoke/compact/test_expectations.yml +0 -18
- data/smoke/const/Steepfile +0 -6
- data/smoke/const/a.rb +0 -27
- data/smoke/const/b.rb +0 -7
- data/smoke/const/b.rbs +0 -5
- data/smoke/const/test_expectations.yml +0 -134
- data/smoke/diagnostics/Steepfile +0 -6
- data/smoke/diagnostics/a.rbs +0 -22
- data/smoke/diagnostics/argument_type_mismatch.rb +0 -1
- data/smoke/diagnostics/block_body_type_mismatch.rb +0 -1
- data/smoke/diagnostics/block_type_mismatch.rb +0 -3
- data/smoke/diagnostics/break_type_mismatch.rb +0 -1
- data/smoke/diagnostics/different_method_parameter_kind.rb +0 -9
- data/smoke/diagnostics/else_on_exhaustive_case.rb +0 -12
- data/smoke/diagnostics/incompatible_annotation.rb +0 -6
- data/smoke/diagnostics/incompatible_argument.rb +0 -1
- data/smoke/diagnostics/incompatible_assignment.rb +0 -8
- data/smoke/diagnostics/method_arity_mismatch.rb +0 -11
- data/smoke/diagnostics/method_body_type_mismatch.rb +0 -6
- data/smoke/diagnostics/method_definition_missing.rb +0 -2
- data/smoke/diagnostics/method_parameter_mismatch.rb +0 -10
- data/smoke/diagnostics/method_return_type_annotation_mismatch.rb +0 -7
- data/smoke/diagnostics/missing_keyword.rb +0 -1
- data/smoke/diagnostics/no_method.rb +0 -1
- data/smoke/diagnostics/proc_type_expected.rb +0 -3
- data/smoke/diagnostics/required_block_missing.rb +0 -1
- data/smoke/diagnostics/return_type_mismatch.rb +0 -6
- data/smoke/diagnostics/test_expectations.yml +0 -591
- data/smoke/diagnostics/unexpected_block_given.rb +0 -1
- data/smoke/diagnostics/unexpected_dynamic_method.rb +0 -3
- data/smoke/diagnostics/unexpected_jump.rb +0 -4
- data/smoke/diagnostics/unexpected_jump_value.rb +0 -3
- data/smoke/diagnostics/unexpected_keyword.rb +0 -1
- data/smoke/diagnostics/unexpected_splat.rb +0 -1
- data/smoke/diagnostics/unexpected_yield.rb +0 -6
- data/smoke/diagnostics/unknown_constant_assigned.rb +0 -7
- data/smoke/diagnostics/unresolved_overloading.rb +0 -1
- data/smoke/diagnostics/unsupported_syntax.rb +0 -2
- data/smoke/diagnostics-rbs/Steepfile +0 -8
- data/smoke/diagnostics-rbs/duplicated-method-definition.rbs +0 -20
- data/smoke/diagnostics-rbs/generic-parameter-mismatch.rbs +0 -7
- data/smoke/diagnostics-rbs/inherit-module.rbs +0 -2
- data/smoke/diagnostics-rbs/invalid-method-overload.rbs +0 -3
- data/smoke/diagnostics-rbs/invalid-type-application.rbs +0 -7
- data/smoke/diagnostics-rbs/invalid_variance_annotation.rbs +0 -3
- data/smoke/diagnostics-rbs/mixin-class-error.rbs +0 -6
- data/smoke/diagnostics-rbs/nonregular-type-alias.rbs +0 -3
- data/smoke/diagnostics-rbs/recursive-alias.rbs +0 -5
- data/smoke/diagnostics-rbs/recursive-class.rbs +0 -8
- data/smoke/diagnostics-rbs/recursive-type-alias.rbs +0 -3
- data/smoke/diagnostics-rbs/superclass-mismatch.rbs +0 -7
- data/smoke/diagnostics-rbs/test_expectations.yml +0 -300
- data/smoke/diagnostics-rbs/unknown-method-alias.rbs +0 -3
- data/smoke/diagnostics-rbs/unknown-type-name-2.rbs +0 -5
- data/smoke/diagnostics-rbs/unknown-type-name.rbs +0 -13
- data/smoke/diagnostics-rbs-duplicated/Steepfile +0 -6
- data/smoke/diagnostics-rbs-duplicated/a.rbs +0 -5
- data/smoke/diagnostics-rbs-duplicated/test_expectations.yml +0 -13
- data/smoke/diagnostics-ruby-unsat/Steepfile +0 -6
- data/smoke/diagnostics-ruby-unsat/a.rbs +0 -3
- data/smoke/diagnostics-ruby-unsat/test_expectations.yml +0 -27
- data/smoke/diagnostics-ruby-unsat/unsatisfiable_constraint.rb +0 -6
- data/smoke/dstr/Steepfile +0 -6
- data/smoke/dstr/a.rb +0 -5
- data/smoke/dstr/test_expectations.yml +0 -13
- data/smoke/ensure/Steepfile +0 -6
- data/smoke/ensure/a.rb +0 -18
- data/smoke/ensure/test_expectations.yml +0 -62
- data/smoke/enumerator/Steepfile +0 -6
- data/smoke/enumerator/a.rb +0 -6
- data/smoke/enumerator/b.rb +0 -17
- data/smoke/enumerator/test_expectations.yml +0 -47
- data/smoke/extension/Steepfile +0 -6
- data/smoke/extension/a.rb +0 -10
- data/smoke/extension/a.rbs +0 -13
- data/smoke/extension/b.rb +0 -10
- data/smoke/extension/c.rb +0 -9
- data/smoke/extension/d.rb +0 -2
- data/smoke/extension/e.rb +0 -2
- data/smoke/extension/e.rbs +0 -7
- data/smoke/extension/f.rb +0 -2
- data/smoke/extension/f.rbs +0 -3
- data/smoke/extension/test_expectations.yml +0 -73
- data/smoke/hash/Steepfile +0 -6
- data/smoke/hash/a.rb +0 -17
- data/smoke/hash/a.rbs +0 -8
- data/smoke/hash/b.rb +0 -6
- data/smoke/hash/c.rb +0 -15
- data/smoke/hash/d.rb +0 -5
- data/smoke/hash/e.rb +0 -1
- data/smoke/hash/e.rbs +0 -3
- data/smoke/hash/f.rb +0 -11
- data/smoke/hash/test_expectations.yml +0 -81
- data/smoke/hello/Steepfile +0 -6
- data/smoke/hello/hello.rb +0 -11
- data/smoke/hello/hello.rbs +0 -7
- data/smoke/hello/test_expectations.yml +0 -25
- data/smoke/if/Steepfile +0 -6
- data/smoke/if/a.rb +0 -20
- data/smoke/if/test_expectations.yml +0 -34
- data/smoke/implements/Steepfile +0 -6
- data/smoke/implements/a.rb +0 -12
- data/smoke/implements/a.rbs +0 -6
- data/smoke/implements/b.rb +0 -13
- data/smoke/implements/b.rbs +0 -12
- data/smoke/implements/test_expectations.yml +0 -23
- data/smoke/initialize/Steepfile +0 -6
- data/smoke/initialize/a.rb +0 -12
- data/smoke/initialize/a.rbs +0 -3
- data/smoke/initialize/test_expectations.yml +0 -1
- data/smoke/integer/Steepfile +0 -6
- data/smoke/integer/a.rb +0 -26
- data/smoke/integer/test_expectations.yml +0 -110
- data/smoke/interface/Steepfile +0 -6
- data/smoke/interface/a.rb +0 -12
- data/smoke/interface/a.rbs +0 -12
- data/smoke/interface/test_expectations.yml +0 -23
- data/smoke/kwbegin/Steepfile +0 -6
- data/smoke/kwbegin/a.rb +0 -7
- data/smoke/kwbegin/test_expectations.yml +0 -17
- data/smoke/lambda/Steepfile +0 -6
- data/smoke/lambda/a.rb +0 -10
- data/smoke/lambda/test_expectations.yml +0 -17
- data/smoke/literal/Steepfile +0 -6
- data/smoke/literal/a.rb +0 -11
- data/smoke/literal/b.rb +0 -7
- data/smoke/literal/literal_methods.rbs +0 -4
- data/smoke/literal/test_expectations.yml +0 -106
- data/smoke/map/Steepfile +0 -6
- data/smoke/map/a.rb +0 -5
- data/smoke/map/test_expectations.yml +0 -1
- data/smoke/method/Steepfile +0 -6
- data/smoke/method/a.rb +0 -21
- data/smoke/method/a.rbs +0 -4
- data/smoke/method/b.rb +0 -25
- data/smoke/method/c.rb +0 -5
- data/smoke/method/d.rb +0 -1
- data/smoke/method/d.rbs +0 -3
- data/smoke/method/test_expectations.yml +0 -121
- data/smoke/module/Steepfile +0 -6
- data/smoke/module/a.rb +0 -19
- data/smoke/module/a.rbs +0 -16
- data/smoke/module/b.rb +0 -6
- data/smoke/module/c.rb +0 -22
- data/smoke/module/d.rb +0 -4
- data/smoke/module/e.rb +0 -13
- data/smoke/module/f.rb +0 -11
- data/smoke/module/test_expectations.yml +0 -75
- data/smoke/regexp/Steepfile +0 -6
- data/smoke/regexp/a.rb +0 -109
- data/smoke/regexp/b.rb +0 -79
- data/smoke/regexp/test_expectations.yml +0 -615
- data/smoke/regression/Steepfile +0 -6
- data/smoke/regression/array.rb +0 -7
- data/smoke/regression/block_param_split.rb +0 -7
- data/smoke/regression/block_param_split.rbs +0 -3
- data/smoke/regression/empty_yield.rb +0 -5
- data/smoke/regression/empty_yield.rbs +0 -3
- data/smoke/regression/enumerator_product.rb +0 -1
- data/smoke/regression/fun.rb +0 -8
- data/smoke/regression/fun.rbs +0 -4
- data/smoke/regression/hash.rb +0 -7
- data/smoke/regression/hello world.rb +0 -1
- data/smoke/regression/issue_328.rb +0 -1
- data/smoke/regression/issue_328.rbs +0 -0
- data/smoke/regression/issue_332.rb +0 -11
- data/smoke/regression/issue_332.rbs +0 -19
- data/smoke/regression/issue_372.rb +0 -8
- data/smoke/regression/issue_372.rbs +0 -4
- data/smoke/regression/lambda.rb +0 -3
- data/smoke/regression/masgn.rb +0 -4
- data/smoke/regression/poly_new.rb +0 -2
- data/smoke/regression/poly_new.rbs +0 -4
- data/smoke/regression/range.rb +0 -5
- data/smoke/regression/set_divide.rb +0 -12
- data/smoke/regression/test_expectations.yml +0 -120
- data/smoke/regression/thread.rb +0 -7
- data/smoke/rescue/Steepfile +0 -6
- data/smoke/rescue/a.rb +0 -48
- data/smoke/rescue/test_expectations.yml +0 -79
- data/smoke/self/Steepfile +0 -6
- data/smoke/self/a.rb +0 -21
- data/smoke/self/a.rbs +0 -4
- data/smoke/self/test_expectations.yml +0 -23
- data/smoke/skip/Steepfile +0 -6
- data/smoke/skip/skip.rb +0 -13
- data/smoke/skip/test_expectations.yml +0 -23
- data/smoke/stdout/Steepfile +0 -6
- data/smoke/stdout/a.rb +0 -8
- data/smoke/stdout/a.rbs +0 -7
- data/smoke/stdout/test_expectations.yml +0 -1
- data/smoke/super/Steepfile +0 -6
- data/smoke/super/a.rb +0 -30
- data/smoke/super/a.rbs +0 -10
- data/smoke/super/test_expectations.yml +0 -69
- data/smoke/toplevel/Steepfile +0 -6
- data/smoke/toplevel/a.rb +0 -3
- data/smoke/toplevel/a.rbs +0 -3
- data/smoke/toplevel/test_expectations.yml +0 -15
- data/smoke/tsort/Steepfile +0 -7
- data/smoke/tsort/a.rb +0 -12
- data/smoke/tsort/test_expectations.yml +0 -1
- data/smoke/type_case/Steepfile +0 -6
- data/smoke/type_case/a.rb +0 -24
- data/smoke/type_case/test_expectations.yml +0 -58
- data/smoke/unexpected/Steepfile +0 -6
- data/smoke/unexpected/test_expectations.yml +0 -13
- data/smoke/unexpected/unexpected.rbs +0 -3
- data/smoke/yield/Steepfile +0 -6
- data/smoke/yield/a.rb +0 -15
- data/smoke/yield/b.rb +0 -6
- data/smoke/yield/test_expectations.yml +0 -88
@@ -878,6 +878,7 @@ module Steep
|
|
878
878
|
if self_type && method_context!.method
|
879
879
|
if super_def = method_context!.super_method
|
880
880
|
super_method = Interface::Shape::Entry.new(
|
881
|
+
private_method: true,
|
881
882
|
method_types: super_def.defs.map {|type_def|
|
882
883
|
decl = TypeInference::MethodCall::MethodDecl.new(
|
883
884
|
method_name: InstanceMethodName.new(
|
@@ -1634,28 +1635,32 @@ module Steep
|
|
1634
1635
|
when :yield
|
1635
1636
|
if method_context && method_context.method_type
|
1636
1637
|
if block_type = method_context.block_type
|
1637
|
-
|
1638
|
-
type
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1638
|
+
if block_type.type.params
|
1639
|
+
type = AST::Types::Proc.new(
|
1640
|
+
type: block_type.type,
|
1641
|
+
block: nil,
|
1642
|
+
self_type: block_type.self_type
|
1643
|
+
)
|
1644
|
+
args = TypeInference::SendArgs.new(
|
1645
|
+
node: node,
|
1646
|
+
arguments: node.children,
|
1647
|
+
type: type
|
1648
|
+
)
|
1647
1649
|
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1650
|
+
# @type var errors: Array[Diagnostic::Ruby::Base]
|
1651
|
+
errors = []
|
1652
|
+
constr = type_check_args(
|
1653
|
+
nil,
|
1654
|
+
args,
|
1655
|
+
Subtyping::Constraints.new(unknowns: []),
|
1656
|
+
errors
|
1657
|
+
)
|
1656
1658
|
|
1657
|
-
|
1658
|
-
|
1659
|
+
errors.each do |error|
|
1660
|
+
typing.add_error(error)
|
1661
|
+
end
|
1662
|
+
else
|
1663
|
+
constr = type_check_untyped_args(node.children)
|
1659
1664
|
end
|
1660
1665
|
|
1661
1666
|
add_typing(node, type: block_type.type.return_type)
|
@@ -1812,7 +1817,7 @@ module Steep
|
|
1812
1817
|
.for_branch(right_node)
|
1813
1818
|
.synthesize(right_node, hint: left_truthy.type, condition: true).to_ary
|
1814
1819
|
|
1815
|
-
right_truthy, right_falsy = interpreter.eval(env:
|
1820
|
+
right_truthy, right_falsy = interpreter.eval(env: right_context.type_env, node: right_node)
|
1816
1821
|
|
1817
1822
|
case
|
1818
1823
|
when left_falsy.unreachable
|
@@ -1966,113 +1971,7 @@ module Steep
|
|
1966
1971
|
interpreter = TypeInference::LogicTypeInterpreter.new(subtyping: checker, typing: typing, config: builder_config)
|
1967
1972
|
|
1968
1973
|
if cond
|
1969
|
-
|
1970
|
-
|
1971
|
-
cond_type, constr = constr.synthesize(cond)
|
1972
|
-
|
1973
|
-
var_name = :"_a[#{SecureRandom.alphanumeric(4)}]"
|
1974
|
-
var_cond, value_node = transform_condition_node(cond, var_name)
|
1975
|
-
constr = constr.update_type_env {|env| env.assign_local_variable(var_name, cond_type, nil) }
|
1976
|
-
|
1977
|
-
next_branch_reachable = true
|
1978
|
-
|
1979
|
-
when_constr = constr
|
1980
|
-
whens.each do |clause|
|
1981
|
-
# @type var tests: Array[Parser::AST::Node]
|
1982
|
-
# @type var body: Parser::AST::Node?
|
1983
|
-
*tests, body = clause.children
|
1984
|
-
|
1985
|
-
test_constr = when_constr
|
1986
|
-
# @type var test_envs: Array[TypeInference::TypeEnv]
|
1987
|
-
test_envs = []
|
1988
|
-
|
1989
|
-
branch_reachable = false
|
1990
|
-
false_branch_reachable = false
|
1991
|
-
|
1992
|
-
tests.each do |test|
|
1993
|
-
test_node = test.updated(:send, [test, :===, var_cond])
|
1994
|
-
test_type, test_constr = test_constr.synthesize(test_node, condition: true).to_ary
|
1995
|
-
truthy, falsy = interpreter.eval(node: test_node, env: test_constr.context.type_env)
|
1996
|
-
|
1997
|
-
truthy_env = propagate_type_env(var_name, value_node, truthy.env)
|
1998
|
-
falsy_env = propagate_type_env(var_name, value_node, falsy.env)
|
1999
|
-
|
2000
|
-
test_envs << truthy_env
|
2001
|
-
|
2002
|
-
test_constr = test_constr.update_type_env { falsy_env }
|
2003
|
-
|
2004
|
-
branch_reachable ||= next_branch_reachable && !truthy.unreachable
|
2005
|
-
false_branch_reachable = !falsy.unreachable
|
2006
|
-
end
|
2007
|
-
|
2008
|
-
next_branch_reachable &&= false_branch_reachable
|
2009
|
-
body_constr = when_constr.update_type_env {|env| env.join(*test_envs) }
|
2010
|
-
|
2011
|
-
branch_result =
|
2012
|
-
if body
|
2013
|
-
body_constr
|
2014
|
-
.for_branch(body)
|
2015
|
-
.tap {|constr| typing.add_context_for_node(body, context: constr.context) }
|
2016
|
-
.synthesize(body, hint: hint)
|
2017
|
-
else
|
2018
|
-
Pair.new(type: AST::Builtin.nil_type, constr: body_constr)
|
2019
|
-
end
|
2020
|
-
|
2021
|
-
branch_results << branch_result
|
2022
|
-
|
2023
|
-
if !branch_reachable && !branch_result.type.is_a?(AST::Types::Bot)
|
2024
|
-
typing.add_error(
|
2025
|
-
Diagnostic::Ruby::UnreachableValueBranch.new(
|
2026
|
-
node: clause,
|
2027
|
-
type: branch_result.type,
|
2028
|
-
location: clause.location.keyword
|
2029
|
-
)
|
2030
|
-
)
|
2031
|
-
end
|
2032
|
-
|
2033
|
-
when_constr = test_constr
|
2034
|
-
end
|
2035
|
-
|
2036
|
-
if els
|
2037
|
-
node.loc.else or raise
|
2038
|
-
|
2039
|
-
begin_pos = node.loc.else.end_pos
|
2040
|
-
end_pos = node.loc.end.begin_pos
|
2041
|
-
typing.add_context(begin_pos..end_pos, context: when_constr.context)
|
2042
|
-
|
2043
|
-
else_result = when_constr.synthesize(els, hint: hint)
|
2044
|
-
|
2045
|
-
if next_branch_reachable
|
2046
|
-
branch_results << else_result
|
2047
|
-
end
|
2048
|
-
end
|
2049
|
-
|
2050
|
-
types = branch_results.map(&:type)
|
2051
|
-
constrs = branch_results.map(&:constr)
|
2052
|
-
|
2053
|
-
if !next_branch_reachable
|
2054
|
-
# Exhaustive
|
2055
|
-
_, _, _, loc = deconstruct_case_node!(node)
|
2056
|
-
|
2057
|
-
# `else` may present even if it's empty
|
2058
|
-
if loc.else
|
2059
|
-
if els
|
2060
|
-
else_result or raise
|
2061
|
-
unless else_result.type.is_a?(AST::Types::Bot)
|
2062
|
-
typing.add_error Diagnostic::Ruby::UnreachableValueBranch.new(
|
2063
|
-
node: els,
|
2064
|
-
type: else_result.type,
|
2065
|
-
location: node.loc.else || raise
|
2066
|
-
)
|
2067
|
-
end
|
2068
|
-
end
|
2069
|
-
end
|
2070
|
-
else
|
2071
|
-
unless els
|
2072
|
-
constrs << when_constr
|
2073
|
-
types << AST::Builtin.nil_type
|
2074
|
-
end
|
2075
|
-
end
|
1974
|
+
types, envs = TypeInference::CaseWhen.type_check(constr, node, interpreter, hint: hint, condition: condition)
|
2076
1975
|
else
|
2077
1976
|
branch_results = [] #: Array[Pair]
|
2078
1977
|
|
@@ -2131,7 +2030,7 @@ module Steep
|
|
2131
2030
|
end
|
2132
2031
|
|
2133
2032
|
types = branch_results.map(&:type)
|
2134
|
-
|
2033
|
+
envs = branch_results.map {|result| result.constr.context.type_env }
|
2135
2034
|
|
2136
2035
|
unless els
|
2137
2036
|
types << AST::Builtin.nil_type
|
@@ -2139,7 +2038,6 @@ module Steep
|
|
2139
2038
|
end
|
2140
2039
|
|
2141
2040
|
constr = constr.update_type_env do |env|
|
2142
|
-
envs = constrs.map {|c| c.context.type_env }
|
2143
2041
|
env.join(*envs)
|
2144
2042
|
end
|
2145
2043
|
|
@@ -2208,6 +2106,7 @@ module Steep
|
|
2208
2106
|
end
|
2209
2107
|
|
2210
2108
|
if body
|
2109
|
+
resbody_construction.typing.add_context_for_node(body, context: resbody_construction.context)
|
2211
2110
|
resbody_construction.synthesize(body, hint: hint)
|
2212
2111
|
else
|
2213
2112
|
Pair.new(constr: body_constr, type: AST::Builtin.nil_type)
|
@@ -2278,10 +2177,21 @@ module Steep
|
|
2278
2177
|
var_type = AST::Builtin.any_type
|
2279
2178
|
else
|
2280
2179
|
if each = calculate_interface(collection_type, :each, private: true)
|
2281
|
-
|
2180
|
+
method_type = (each.method_types || []).find do |type|
|
2181
|
+
if type.block
|
2182
|
+
if type.block.type.params
|
2183
|
+
type.block.type.params.first_param
|
2184
|
+
else
|
2185
|
+
true
|
2186
|
+
end
|
2187
|
+
end
|
2188
|
+
end
|
2189
|
+
if method_type
|
2282
2190
|
if block = method_type.block
|
2283
|
-
if first_param = block.type
|
2191
|
+
if first_param = block.type&.params&.first_param
|
2284
2192
|
var_type = first_param.type #: AST::Types::t
|
2193
|
+
else
|
2194
|
+
var_type - AST::Builtin.any_type
|
2285
2195
|
end
|
2286
2196
|
end
|
2287
2197
|
end
|
@@ -2455,11 +2365,8 @@ module Steep
|
|
2455
2365
|
end
|
2456
2366
|
|
2457
2367
|
when :defined?
|
2458
|
-
|
2459
|
-
|
2460
|
-
end
|
2461
|
-
|
2462
|
-
add_typing(node, type: AST::Builtin.any_type)
|
2368
|
+
type_any_rec(node, only_children: true)
|
2369
|
+
add_typing(node, type: AST::Builtin.optional(AST::Builtin::String.instance_type))
|
2463
2370
|
|
2464
2371
|
when :gvasgn
|
2465
2372
|
yield_self do
|
@@ -2495,31 +2402,33 @@ module Steep
|
|
2495
2402
|
|
2496
2403
|
if hint.is_a?(AST::Types::Proc) && value_node.type == :sym
|
2497
2404
|
if hint.one_arg?
|
2498
|
-
|
2499
|
-
|
2500
|
-
|
2501
|
-
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2507
|
-
method_type.type.
|
2405
|
+
if hint.type.params
|
2406
|
+
# Assumes Symbol#to_proc implementation
|
2407
|
+
param_type = hint.type.params.required[0]
|
2408
|
+
case param_type
|
2409
|
+
when AST::Types::Any
|
2410
|
+
type = AST::Types::Any.new
|
2411
|
+
else
|
2412
|
+
if method = calculate_interface(param_type, private: true)&.methods&.[](value_node.children[0])
|
2413
|
+
return_types = method.method_types.filter_map do |method_type|
|
2414
|
+
if method_type.type.params.nil? || method_type.type.params.optional?
|
2415
|
+
method_type.type.return_type
|
2416
|
+
end
|
2508
2417
|
end
|
2509
|
-
end
|
2510
2418
|
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2419
|
+
unless return_types.empty?
|
2420
|
+
type = AST::Types::Proc.new(
|
2421
|
+
type: Interface::Function.new(
|
2422
|
+
params: Interface::Function::Params.empty.with_first_param(
|
2423
|
+
Interface::Function::Params::PositionalParams::Required.new(param_type)
|
2424
|
+
),
|
2425
|
+
return_type: return_types[0],
|
2426
|
+
location: nil
|
2516
2427
|
),
|
2517
|
-
|
2518
|
-
|
2519
|
-
)
|
2520
|
-
|
2521
|
-
self_type: nil
|
2522
|
-
)
|
2428
|
+
block: nil,
|
2429
|
+
self_type: nil
|
2430
|
+
)
|
2431
|
+
end
|
2523
2432
|
end
|
2524
2433
|
end
|
2525
2434
|
end
|
@@ -2721,6 +2630,7 @@ module Steep
|
|
2721
2630
|
end
|
2722
2631
|
end
|
2723
2632
|
rescue RBS::BaseError => exn
|
2633
|
+
Steep.logger.warn("hello")
|
2724
2634
|
Steep.logger.warn { "Unexpected RBS error: #{exn.message}" }
|
2725
2635
|
exn.backtrace&.each {|loc| Steep.logger.warn " #{loc}" }
|
2726
2636
|
typing.add_error(Diagnostic::Ruby::UnexpectedError.new(node: node, error: exn))
|
@@ -3294,7 +3204,7 @@ module Steep
|
|
3294
3204
|
end
|
3295
3205
|
|
3296
3206
|
def type_send_interface(node, interface:, receiver:, receiver_type:, method_name:, arguments:, block_params:, block_body:, tapp:, hint:)
|
3297
|
-
method = interface
|
3207
|
+
method = interface.methods[method_name]
|
3298
3208
|
|
3299
3209
|
if method
|
3300
3210
|
call, constr = type_method_call(
|
@@ -3541,16 +3451,16 @@ module Steep
|
|
3541
3451
|
self_type: self_type,
|
3542
3452
|
class_type: module_context.module_type,
|
3543
3453
|
instance_type: module_context.instance_type,
|
3544
|
-
variable_bounds: variable_context.upper_bounds
|
3454
|
+
variable_bounds: context.variable_context.upper_bounds
|
3545
3455
|
)
|
3546
3456
|
end
|
3547
3457
|
|
3548
3458
|
def calculate_interface(type, method_name = nil, private:)
|
3549
|
-
shape = checker.builder.shape(
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3459
|
+
shape = checker.builder.shape(type, builder_config)
|
3460
|
+
|
3461
|
+
unless private
|
3462
|
+
shape = shape&.public_shape
|
3463
|
+
end
|
3554
3464
|
|
3555
3465
|
if method_name
|
3556
3466
|
if shape
|
@@ -3732,10 +3642,6 @@ module Steep
|
|
3732
3642
|
end
|
3733
3643
|
end
|
3734
3644
|
|
3735
|
-
def inspect
|
3736
|
-
"#<#{self.class}>"
|
3737
|
-
end
|
3738
|
-
|
3739
3645
|
def with_child_typing(range:)
|
3740
3646
|
constr = with_new_typing(typing.new_child(range))
|
3741
3647
|
|
@@ -4027,13 +3933,17 @@ module Steep
|
|
4027
3933
|
# @type var errors: Array[Diagnostic::Ruby::Base]
|
4028
3934
|
errors = []
|
4029
3935
|
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4035
|
-
|
4036
|
-
|
3936
|
+
if method_type.type.params
|
3937
|
+
args = TypeInference::SendArgs.new(node: node, arguments: arguments, type: method_type)
|
3938
|
+
constr = constr.type_check_args(
|
3939
|
+
method_name,
|
3940
|
+
args,
|
3941
|
+
constraints,
|
3942
|
+
errors
|
3943
|
+
)
|
3944
|
+
else
|
3945
|
+
constr = constr.type_check_untyped_args(arguments)
|
3946
|
+
end
|
4037
3947
|
|
4038
3948
|
if block_params
|
4039
3949
|
# block is given
|
@@ -4122,11 +4032,12 @@ module Steep
|
|
4122
4032
|
end
|
4123
4033
|
|
4124
4034
|
method_type, solved, s = apply_solution(errors, node: node, method_type: method_type) {
|
4125
|
-
|
4126
|
-
|
4127
|
-
|
4128
|
-
|
4129
|
-
|
4035
|
+
fvs_ = Set[] #: Set[AST::Types::variable]
|
4036
|
+
|
4037
|
+
fvs_.merge(method_type.type.params.free_variables) if method_type.type.params
|
4038
|
+
fvs_.merge(method_type.block.type.params.free_variables) if method_type.block.type.params
|
4039
|
+
|
4040
|
+
constraints.solution(checker, variables: fvs_, context: ccontext)
|
4130
4041
|
}
|
4131
4042
|
|
4132
4043
|
method_type.block or raise
|
@@ -4214,129 +4125,143 @@ module Steep
|
|
4214
4125
|
return_type = method_type.type.return_type
|
4215
4126
|
end
|
4216
4127
|
else
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4128
|
+
if args
|
4129
|
+
# Block is given but method doesn't accept
|
4130
|
+
#
|
4131
|
+
constr.type_block_without_hint(node: node, block_annotations: block_annotations, block_params: block_params_, block_body: block_body) do |error|
|
4132
|
+
errors << error
|
4133
|
+
end
|
4222
4134
|
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4228
|
-
|
4135
|
+
case node.children[0].type
|
4136
|
+
when :super, :zsuper
|
4137
|
+
unless method_context!.super_method
|
4138
|
+
errors << Diagnostic::Ruby::UnexpectedSuper.new(
|
4139
|
+
node: node.children[0],
|
4140
|
+
method: method_name
|
4141
|
+
)
|
4142
|
+
end
|
4143
|
+
else
|
4144
|
+
errors << Diagnostic::Ruby::UnexpectedBlockGiven.new(
|
4145
|
+
node: node,
|
4146
|
+
method_type: method_type
|
4229
4147
|
)
|
4230
4148
|
end
|
4149
|
+
|
4150
|
+
method_type = eliminate_vars(method_type, type_param_names)
|
4151
|
+
return_type = method_type.type.return_type
|
4231
4152
|
else
|
4232
|
-
|
4233
|
-
|
4234
|
-
|
4235
|
-
|
4153
|
+
if block_body
|
4154
|
+
block_annotations = source.annotations(block: node, factory: checker.factory, context: nesting)
|
4155
|
+
type_block_without_hint(
|
4156
|
+
node: node,
|
4157
|
+
block_annotations: block_annotations,
|
4158
|
+
block_params: TypeInference::BlockParams.from_node(block_params, annotations: block_annotations),
|
4159
|
+
block_body: block_body
|
4160
|
+
)
|
4161
|
+
end
|
4236
4162
|
end
|
4237
|
-
|
4238
|
-
method_type = eliminate_vars(method_type, type_param_names)
|
4239
|
-
return_type = method_type.type.return_type
|
4240
4163
|
end
|
4241
4164
|
else
|
4242
4165
|
# Block syntax is not given
|
4243
|
-
|
4166
|
+
if args
|
4167
|
+
arg = args.block_pass_arg
|
4244
4168
|
|
4245
|
-
|
4246
|
-
|
4247
|
-
|
4169
|
+
case
|
4170
|
+
when forwarded_args_node = args.forwarded_args_node
|
4171
|
+
(_, block = method_context!.forward_arg_type) or raise
|
4248
4172
|
|
4249
|
-
|
4250
|
-
|
4173
|
+
method_block_type = method_type.block&.to_proc_type || AST::Builtin.nil_type
|
4174
|
+
forwarded_block_type = block&.to_proc_type || AST::Builtin.nil_type
|
4251
4175
|
|
4252
|
-
|
4253
|
-
|
4254
|
-
|
4255
|
-
|
4256
|
-
|
4257
|
-
|
4258
|
-
|
4259
|
-
|
4176
|
+
if result = constr.no_subtyping?(sub_type: forwarded_block_type, super_type: method_block_type)
|
4177
|
+
errors << Diagnostic::Ruby::IncompatibleArgumentForwarding.new(
|
4178
|
+
method_name: method_name,
|
4179
|
+
node: forwarded_args_node,
|
4180
|
+
block_pair: [block, method_type.block],
|
4181
|
+
result: result
|
4182
|
+
)
|
4183
|
+
end
|
4260
4184
|
|
4261
|
-
|
4262
|
-
|
4263
|
-
|
4264
|
-
|
4185
|
+
when arg.compatible?
|
4186
|
+
if arg.node
|
4187
|
+
# Block pass (&block) is given
|
4188
|
+
node_type, constr = constr.synthesize(arg.node, hint: arg.node_type)
|
4265
4189
|
|
4266
|
-
|
4267
|
-
|
4268
|
-
|
4190
|
+
nil_given =
|
4191
|
+
constr.check_relation(sub_type: node_type, super_type: AST::Builtin.nil_type).success? &&
|
4192
|
+
!node_type.is_a?(AST::Types::Any)
|
4269
4193
|
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
|
4274
|
-
|
4275
|
-
|
4194
|
+
if nil_given
|
4195
|
+
# nil is given ==> no block arg node is given
|
4196
|
+
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4197
|
+
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4198
|
+
}
|
4199
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4276
4200
|
|
4277
|
-
|
4278
|
-
|
4279
|
-
|
4280
|
-
|
4281
|
-
)
|
4282
|
-
else
|
4283
|
-
# non-nil value is given
|
4284
|
-
constr.check_relation(sub_type: node_type, super_type: arg.node_type, constraints: constraints).else do |result|
|
4285
|
-
errors << Diagnostic::Ruby::BlockTypeMismatch.new(
|
4286
|
-
node: arg.node,
|
4287
|
-
expected: arg.node_type,
|
4288
|
-
actual: node_type,
|
4289
|
-
result: result
|
4201
|
+
# Passing no block
|
4202
|
+
errors << Diagnostic::Ruby::RequiredBlockMissing.new(
|
4203
|
+
node: node,
|
4204
|
+
method_type: method_type
|
4290
4205
|
)
|
4291
|
-
|
4206
|
+
else
|
4207
|
+
# non-nil value is given
|
4208
|
+
constr.check_relation(sub_type: node_type, super_type: arg.node_type, constraints: constraints).else do |result|
|
4209
|
+
errors << Diagnostic::Ruby::BlockTypeMismatch.new(
|
4210
|
+
node: arg.node,
|
4211
|
+
expected: arg.node_type,
|
4212
|
+
actual: node_type,
|
4213
|
+
result: result
|
4214
|
+
)
|
4215
|
+
end
|
4292
4216
|
|
4217
|
+
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4218
|
+
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4219
|
+
}
|
4220
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4221
|
+
end
|
4222
|
+
else
|
4223
|
+
# Block is not given
|
4293
4224
|
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4294
4225
|
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4295
4226
|
}
|
4296
4227
|
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4297
4228
|
end
|
4298
|
-
|
4299
|
-
|
4229
|
+
|
4230
|
+
return_type = method_type.type.return_type
|
4231
|
+
|
4232
|
+
when arg.block_missing?
|
4233
|
+
# Block is required but not given
|
4300
4234
|
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4301
4235
|
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4302
4236
|
}
|
4303
|
-
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4304
|
-
end
|
4305
4237
|
|
4306
|
-
|
4307
|
-
|
4308
|
-
when arg.block_missing?
|
4309
|
-
# Block is required but not given
|
4310
|
-
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4311
|
-
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4312
|
-
}
|
4313
|
-
|
4314
|
-
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4315
|
-
return_type = method_type.type.return_type
|
4238
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4239
|
+
return_type = method_type.type.return_type
|
4316
4240
|
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4241
|
+
errors << Diagnostic::Ruby::RequiredBlockMissing.new(
|
4242
|
+
node: node,
|
4243
|
+
method_type: method_type
|
4244
|
+
)
|
4321
4245
|
|
4322
|
-
|
4323
|
-
|
4246
|
+
when arg.unexpected_block?
|
4247
|
+
# Unexpected block pass node is given
|
4324
4248
|
|
4325
|
-
|
4249
|
+
arg.node or raise
|
4326
4250
|
|
4327
|
-
|
4328
|
-
|
4329
|
-
|
4330
|
-
|
4331
|
-
|
4251
|
+
method_type, solved, _ = apply_solution(errors, node: node, method_type: method_type) {
|
4252
|
+
constraints.solution(checker, variables: method_type.free_variables, context: ccontext)
|
4253
|
+
}
|
4254
|
+
method_type = eliminate_vars(method_type, type_param_names) unless solved
|
4255
|
+
return_type = method_type.type.return_type
|
4332
4256
|
|
4333
|
-
|
4257
|
+
node_type, constr = constr.synthesize(arg.node)
|
4334
4258
|
|
4335
|
-
|
4336
|
-
|
4337
|
-
|
4338
|
-
|
4339
|
-
|
4259
|
+
unless constr.check_relation(sub_type: node_type, super_type: AST::Builtin.nil_type).success?
|
4260
|
+
errors << Diagnostic::Ruby::UnexpectedBlockGiven.new(
|
4261
|
+
node: node,
|
4262
|
+
method_type: method_type
|
4263
|
+
)
|
4264
|
+
end
|
4340
4265
|
end
|
4341
4266
|
end
|
4342
4267
|
end
|
@@ -4463,7 +4388,7 @@ module Steep
|
|
4463
4388
|
def for_block(body_node, block_params:, block_param_hint:, block_type_hint:, block_block_hint:, block_annotations:, node_type_hint:, block_self_hint:)
|
4464
4389
|
block_param_pairs = block_param_hint && block_params.zip(block_param_hint, block_block_hint, factory: checker.factory)
|
4465
4390
|
|
4466
|
-
# @type var param_types_hash: Hash[Symbol
|
4391
|
+
# @type var param_types_hash: Hash[Symbol?, AST::Types::t]
|
4467
4392
|
param_types_hash = {}
|
4468
4393
|
if block_param_pairs
|
4469
4394
|
block_param_pairs.each do |param, type|
|
@@ -4498,10 +4423,12 @@ module Steep
|
|
4498
4423
|
end
|
4499
4424
|
end
|
4500
4425
|
|
4501
|
-
param_types_hash.delete_if {|name, _| SPECIAL_LVAR_NAMES.include?(name) }
|
4426
|
+
param_types_hash.delete_if {|name, _| name && SPECIAL_LVAR_NAMES.include?(name) }
|
4502
4427
|
|
4503
4428
|
param_types = param_types_hash.each.with_object({}) do |pair, hash| #$ Hash[Symbol, [AST::Types::t, AST::Types::t?]]
|
4504
4429
|
name, type = pair
|
4430
|
+
# skip unamed arguments `*`, `**` and `&`
|
4431
|
+
next if name.nil?
|
4505
4432
|
hash[name] = [type, nil]
|
4506
4433
|
end
|
4507
4434
|
|
@@ -4774,8 +4701,8 @@ module Steep
|
|
4774
4701
|
!nodes.empty? && nodes.all? {|child| child.type == :class || child.type == :module}
|
4775
4702
|
end
|
4776
4703
|
|
4777
|
-
def type_any_rec(node)
|
4778
|
-
add_typing node, type: AST::Builtin.any_type
|
4704
|
+
def type_any_rec(node, only_children: false)
|
4705
|
+
add_typing node, type: AST::Builtin.any_type unless only_children
|
4779
4706
|
|
4780
4707
|
each_child_node(node) do |child|
|
4781
4708
|
type_any_rec(child)
|
@@ -4906,7 +4833,7 @@ module Steep
|
|
4906
4833
|
if shape = calculate_interface(type, private: false)
|
4907
4834
|
if entry = shape.methods[method]
|
4908
4835
|
method_type = entry.method_types.find do |method_type|
|
4909
|
-
method_type.type.params.optional?
|
4836
|
+
method_type.type.params.nil? || method_type.type.params.optional?
|
4910
4837
|
end
|
4911
4838
|
|
4912
4839
|
method_type.type.return_type if method_type
|
@@ -5162,22 +5089,6 @@ module Steep
|
|
5162
5089
|
with_new_typing(typing.parent || raise)
|
5163
5090
|
end
|
5164
5091
|
|
5165
|
-
def transform_condition_node(node, var_name)
|
5166
|
-
case node.type
|
5167
|
-
when :lvasgn
|
5168
|
-
name, rhs = node.children
|
5169
|
-
rhs, value_node = transform_condition_node(rhs, var_name)
|
5170
|
-
[node.updated(nil, [name, rhs]), value_node]
|
5171
|
-
when :begin
|
5172
|
-
*children, last = node.children
|
5173
|
-
last, value_node = transform_condition_node(last, var_name)
|
5174
|
-
[node.updated(nil, children.push(last)), value_node]
|
5175
|
-
else
|
5176
|
-
var_node = node.updated(:lvar, [var_name])
|
5177
|
-
[var_node, node]
|
5178
|
-
end
|
5179
|
-
end
|
5180
|
-
|
5181
5092
|
def type_name(type)
|
5182
5093
|
case type
|
5183
5094
|
when AST::Types::Name::Instance, AST::Types::Name::Singleton
|
@@ -5228,20 +5139,5 @@ module Steep
|
|
5228
5139
|
end
|
5229
5140
|
end
|
5230
5141
|
end
|
5231
|
-
|
5232
|
-
def propagate_type_env(source, dest, env)
|
5233
|
-
source_type = env[source] or raise
|
5234
|
-
|
5235
|
-
if dest.type == :lvar
|
5236
|
-
var_name = dest.children[0] #: Symbol
|
5237
|
-
env.assign_local_variable(var_name, source_type, nil)
|
5238
|
-
else
|
5239
|
-
if env[dest]
|
5240
|
-
env.replace_pure_call_type(dest, source_type)
|
5241
|
-
else
|
5242
|
-
env
|
5243
|
-
end
|
5244
|
-
end
|
5245
|
-
end
|
5246
5142
|
end
|
5247
5143
|
end
|