Class: Jade::Frontend::SemanticAnalysis::Error::PredicateNameNotAllowed

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

Overview

Names ending in ‘?` are reserved for function declarations. Using the `?` suffix on a variable, parameter, or destructured binding would let a non-Bool value shadow the predicate convention.

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, name:) ⇒ PredicateNameNotAllowed

Returns a new instance of PredicateNameNotAllowed.



9
10
11
12
# File 'lib/jade/frontend/semantic_analysis/error/predicate_name_not_allowed.rb', line 9

def initialize(entry, span, name:)
  super(entry:, span:)
  @name = name
end

Instance Method Details

#labelObject



18
19
20
# File 'lib/jade/frontend/semantic_analysis/error/predicate_name_not_allowed.rb', line 18

def label
  "`?` only on function names"
end

#messageObject



14
15
16
# File 'lib/jade/frontend/semantic_analysis/error/predicate_name_not_allowed.rb', line 14

def message
  "`#{@name}` ends in `?` but only function names may use that suffix."
end