msg.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /**
  2. * Error Message Templates
  3. */
  4. const INDENT = ' '
  5. const MSG = {
  6. invalid_code_point: index => `invalid code point 0x${index}`,
  7. variable_not_declared: name => `variable ${name} not declared`,
  8. variable_not_found: name => `variable ${name} not found`,
  9. variable_declared: name => `variable ${name} already declared`,
  10. variable_invalid: name => `invalid value assigned to variable ${name}`,
  11. variable_fixed: name => `cannot reset fixed variable ${name}`,
  12. variable_inconsistent: (name, p) => (
  13. `the value of variable ${name} violated its type constraint`
  14. + (p? `, called through UFCS at ${p}`: '')
  15. ),
  16. static_conflict: name => `static value conflict with argument ${name}`,
  17. arg_wrong_quantity: (r, g) => `${r} arguments required but ${g} given`,
  18. arg_invalid: name => `invalid argument ${name}`,
  19. arg_require_bool: name => `lazy argument ${name} requires a boolean value`,
  20. arg_invalid_inflate: name => (
  21. `invalid template argument ${name}: neither a type nor a primitive`
  22. ),
  23. retval_invalid: 'invalid return value',
  24. retval_invalid_inflate: 'return value of type template should be a type',
  25. non_callable: p => `unable to call non-callable object at ${p}`,
  26. no_matching_function: available => (
  27. 'invalid arguments: no matching function'
  28. + LF + LF + 'Available functions are: '
  29. + LF + LF + available
  30. ),
  31. superset_invalid: i => (
  32. `superset #${i} is invalid (should be Class or Interface)`
  33. ),
  34. method_conflict: (name, X1, X2) => (
  35. 'method conflict:'
  36. + LF + INDENT + X1
  37. + LF + 'and'
  38. + LF + INDENT + X2
  39. + LF + `both have method: ${name}()`
  40. ),
  41. method_missing: (name, C, I) => (
  42. `The ${C}` + LF + 'does not implement'
  43. + LF + INDENT + I
  44. + LF + `(missing method ${name}())`
  45. ),
  46. method_invalid: (name, C, I) => (
  47. `The ${C}` + LF + 'does not implement'
  48. + LF + INDENT + I
  49. + LF + `(invalid method ${name}())`
  50. ),
  51. operator_conflict: (op, C1, C2) => (
  52. `operator ${op} defined in ${C1}`
  53. + LF + `conflicts with the operator ${op} defined in`
  54. + LF + INDENT + C2
  55. ),
  56. interface_invalid: name => (
  57. `invalid interface: blank method ${name}() should not be implemented`
  58. ),
  59. pf_conflict: name => (
  60. `unable to declare private function ${name}: conflict with arguments`
  61. ),
  62. self_conflict: (
  63. `unable to declare 'self' reference: variable name already used`
  64. ),
  65. invalid_push: 'push operator is only available inside observer',
  66. invalid_mount: 'mount operator is only available inside initializer',
  67. mounting_non_instance: 'unable to mount non-instance object',
  68. mounting_undeclared: C => (
  69. 'unable to mount instance of undeclared base class:'
  70. + LF + INDENT + C
  71. ),
  72. mounting_mounted: 'an instance of the same base class is already mounted',
  73. not_mounting: C => `created instance did not mount an instance of ${C}`,
  74. method_not_found: (name, p) => (
  75. `method ${name}() does not exist, called at ${p}`
  76. ),
  77. creator_returned_invalid: 'the creator returned an invalid instance',
  78. format_invalid_key: key => (
  79. `key '${key}' does not exist in given Hash or Struct`
  80. ),
  81. format_invalid_index: index => (
  82. `${'${'+(index+1)+'}'} (index ${index}) does not exist in given list`
  83. ),
  84. format_not_all_converted: (
  85. 'not all elements in list converted during formatting string'
  86. ),
  87. format_none_converted: (
  88. 'none of entries in struct/hash converted during formatting string'
  89. ),
  90. format_empty_list: 'unable to format string by empty list',
  91. hash_invalid_delete: 'deleting a non-existing entry of hash',
  92. get_from_nil: 'unable to perform get operation on Nil without nil flag',
  93. key_error: key => `key error: requested key '${key}' does not exist`,
  94. index_error: index => `index ${index} out of range`,
  95. not_bool: 'given expression did not evaluate to a boolean value',
  96. not_type: 'given expression did not evaluate to a type object',
  97. not_awaitable: 'expression to await did not evaluate to a awaitable value',
  98. not_iterable: i => `comprehension argument #${i} is not iterable`,
  99. element_not_iterable: 'flat(): non-iterable element appeared in sequence',
  100. value_not_observable: 'flat(): non-observable value appeared in sequence',
  101. filter_not_bool: 'given filter function did not return a boolean value',
  102. cond_not_bool: 'given condition function did not return a boolean value',
  103. element_not_string: 'non-string element was found in the iterable object',
  104. invalid_range: (a, b) => (
  105. `invalid range: begin index ${a} is bigger than end index ${b}`
  106. ),
  107. empty_list: 'invalid element access on empty list',
  108. invalid_slice: 'invalid slice: lower bound is bigger than higher bound',
  109. slice_index_error: index => `slice index ${index} out of range`,
  110. invalid_splice: a => `invalid splice amount ${a}`,
  111. invalid_struct_init_miss: k => (
  112. `invalid structure initialization: missing field '${k}'`
  113. ),
  114. invalid_struct_init_key: k => (
  115. `invalid structure initialization: invalid value for field '${k}'`
  116. ),
  117. schema_invalid_field: f => `constraint given for field ${f} is not a type`,
  118. schema_invalid_default: f => `invalid default value for field '${f}'`,
  119. schema_field_conflict: f => `field '${f}' was defined twice or more`,
  120. struct_field_missing: k => `field '${k}' does not exist on the struct`,
  121. struct_field_invalid: k => (
  122. `given value for field '${k}' violated the schema of the struct`
  123. ),
  124. struct_inconsistent: k => (
  125. `the value of field '${k}' became violating the schema`
  126. ),
  127. struct_nil_flag: 'cannot use nil flag on struct field',
  128. different_schema: (
  129. 'cannot apply infix operator on structures of different schema'
  130. ),
  131. not_schema: 'cannot create new structure by a non-schema object',
  132. bad_entry_list: (
  133. 'bad entry list: the number of keys != the number of values'
  134. ),
  135. no_common_class: op => (
  136. (`unable to find a common class of both
  137. instances that defined operator ${op}`).replace(/\n[\t ]*/g, ' ')
  138. ),
  139. module_conflict: mod => `conflicting module name ${mod}`,
  140. missing_export: (mod, exp) => (
  141. `exported variable '${exp}' does not exist in module ${mod}`
  142. ),
  143. import_conflict: alias => (
  144. `invalid import: variable '${alias}' already declared`
  145. ),
  146. import_conflict_mod: (mod, alias) => (
  147. `cannot import module ${mod} as '${alias}': variable already declared`
  148. ),
  149. module_not_exist: mod => `module ${mod} does not exist`,
  150. not_repr: p => 'string format parameter ${' + p + '} is not representable',
  151. when_expr_failed: 'unable to find correct branch in this when expression',
  152. match_expr_failed: 'unable to find correct branch in this match expression',
  153. switch_cmd_failed: 'unable to find correct branch in this switch command',
  154. signature_invalid_arg: i => (
  155. `invalid function signature: non-type object given for parameter #${i}`
  156. ),
  157. signature_invalid_ret: (
  158. 'invalid function signature: non-type object given for return value'
  159. ),
  160. invalid_cast: 'invalid type cast: object was cast to non-desired type',
  161. invalid_copy: (
  162. 'bad copy: new object must be an instance of the class of old one'
  163. ),
  164. did_not_copy: 'bad copy: new object is the same as old one',
  165. replace_not_string: (
  166. 'bad string replace: given function returned a non-string value'
  167. ),
  168. regexp_invalid: 'invalid regular expression',
  169. sqrt_of_negative: (
  170. 'unable to find the real square root of a negative number'
  171. ),
  172. log_of_non_positive: (
  173. 'unable to find the real logarithm of a non-positive number'
  174. ),
  175. asin_out_of_domain: (
  176. 'given argument exceeded the domain of arcsin function'
  177. ),
  178. acos_out_of_domain: (
  179. 'given argument exceeded the domain of arccos function'
  180. ),
  181. match_non_getter: (
  182. 'cannot perform (sub-)pattern matching on a non-GeneralGetter object'
  183. ),
  184. match_nil: (
  185. 'cannot perform (sub-)pattren matching on Nil without nil flag'
  186. ),
  187. invalid_unsub: 'unable to unsubscribe a non-unsubscrible observer',
  188. debounce_invalid_duration: (
  189. 'debounce(): invalid duration returned by given function'
  190. ),
  191. throttle_invalid_duration: (
  192. 'throttle(): invalid duration returned by given function'
  193. ),
  194. invalid_tree_node_inflater: (
  195. 'invalid tree node inflater: should be a $<Hash,List><?>'
  196. ),
  197. scanf_not_found: (
  198. 'using read() requires you to have "node-scanf" module installed'
  199. )
  200. }