Class: Jade::Frontend::SemanticAnalysis::Error::ConstructorNotFound

Inherits:
Error
  • Object
show all
Defined in:
lib/jade/frontend/semantic_analysis/error/constructor_not_found.rb

Defined Under Namespace

Classes: Hint

Instance Attribute Summary collapse

Attributes inherited from Error

#entry, #span

Instance Method Summary collapse

Methods inherited from Error

#notes, #to_diagnostic

Constructor Details

#initialize(entry, span, name:, hint: nil, candidates: []) ⇒ ConstructorNotFound

Returns a new instance of ConstructorNotFound.



13
14
15
16
17
18
# File 'lib/jade/frontend/semantic_analysis/error/constructor_not_found.rb', line 13

def initialize(entry, span, name:, hint: nil, candidates: [])
  @name = name
  @hint = hint
  @candidates = candidates
  super(entry:, span:)
end

Instance Attribute Details

#candidatesObject (readonly)

Returns the value of attribute candidates.



11
12
13
# File 'lib/jade/frontend/semantic_analysis/error/constructor_not_found.rb', line 11

def candidates
  @candidates
end

Instance Method Details

#labelObject



38
39
40
# File 'lib/jade/frontend/semantic_analysis/error/constructor_not_found.rb', line 38

def label
  "not found"
end

#messageObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jade/frontend/semantic_analysis/error/constructor_not_found.rb', line 20

def message
  base = "I cannot find a `#{@name}` constructor"

  case @hint
  in nil
    base

  in Hint(module_name:, type_name:, fix: :expose)
    "#{base}. The type `#{type_name}` is exposed by `#{module_name}` but its " \
      "constructor is private — add `#{type_name}(..)` to that module's " \
      "`exposing` list."

  in Hint(module_name:, type_name:, fix: :import)
    "#{base}. `#{module_name}` exposes it — add `#{type_name}(..)` to this " \
      "module's `import #{module_name} exposing (...)`."
  end
end

#queried_nameObject



42
43
44
# File 'lib/jade/frontend/semantic_analysis/error/constructor_not_found.rb', line 42

def queried_name
  @name
end