Skip to content

Commit

Permalink
Avoid infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke committed Jul 15, 2022
1 parent 8123d46 commit 31fd0b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/rbs/environment_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def initialize(core_root: DEFAULT_CORE_ROOT, repository: Repository.new)
@core_root = core_root
@repository = repository

@libs = []
@libs = Set.new
@dirs = []
end

Expand All @@ -43,8 +43,9 @@ def add(path: nil, library: nil, version: nil, resolve_dependencies: true)
when path
dirs << path
when library
libs << Library.new(name: library, version: version)
resolve_dependencies(library: library, version: version) if resolve_dependencies
if libs.add?(Library.new(name: library, version: version)) && resolve_dependencies
resolve_dependencies(library: library, version: version)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion sig/environment_loader.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module RBS
attr_reader core_root: Pathname?
attr_reader repository: Repository

attr_reader libs: Array[Library]
attr_reader libs: Set[Library]
attr_reader dirs: Array[Pathname]

# The source where the RBS comes from.
Expand Down

0 comments on commit 31fd0b5

Please sign in to comment.