Class: Jade::Frontend::SemanticAnalysis::Error::ConstructorPatternArityMismatch

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

Instance Attribute Summary

Attributes inherited from Error

#entry, #span

Instance Method Summary collapse

Methods inherited from Error

#candidates, #notes, #queried_name, #to_diagnostic

Constructor Details

#initialize(entry, span, constructor:, expected_arity:, actual_arity:) ⇒ ConstructorPatternArityMismatch

Returns a new instance of ConstructorPatternArityMismatch.



6
7
8
9
10
11
# File 'lib/jade/frontend/semantic_analysis/error/constructor_pattern_arity_mismatch.rb', line 6

def initialize(entry, span, constructor:, expected_arity:, actual_arity:)
  super(entry:, span:)
  @constructor = constructor
  @expected_arity = expected_arity
  @actual_arity = actual_arity
end

Instance Method Details

#labelObject



17
18
19
# File 'lib/jade/frontend/semantic_analysis/error/constructor_pattern_arity_mismatch.rb', line 17

def label
  "expected #{@expected_arity} pattern#{@expected_arity > 1 ? 's' : ''}, got #{@actual_arity}"
end

#messageObject



13
14
15
# File 'lib/jade/frontend/semantic_analysis/error/constructor_pattern_arity_mismatch.rb', line 13

def message
  "Arity mismatch, #{@constructor} expects #{@expected_arity} patterns but found #{@actual_arity}"
end