errors.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  1. package checker
  2. import (
  3. "fmt"
  4. "strconv"
  5. "strings"
  6. "kumachan/standalone/util/richtext"
  7. "kumachan/interpreter/lang/common/source"
  8. )
  9. const BlockClassError = "error"
  10. const BlockClassErrorContentItem = "error-content-item"
  11. func makeErrorDescBlankBlock() richtext.Block {
  12. var b richtext.Block
  13. b.AddClass(BlockClassError)
  14. b.WriteSpan("Error: ", richtext.TAG_EM)
  15. return b
  16. }
  17. func makeErrorDescBlock(msg ...string) richtext.Block {
  18. var b = makeErrorDescBlankBlock()
  19. for i, span := range msg {
  20. b.WriteSpan(span, (func() string {
  21. if (i % 2) == 0 {
  22. if strings.HasPrefix(span, "(") && strings.HasSuffix(span, ")") {
  23. return richtext.TAG_ERR_NOTE
  24. } else {
  25. return richtext.TAG_ERR_NORMAL
  26. }
  27. } else {
  28. return richtext.TAG_ERR_INLINE
  29. }
  30. })())
  31. }
  32. return b
  33. }
  34. func makeEmptyErrorContentItemBlock() richtext.Block {
  35. var b richtext.Block
  36. b.AddClass(BlockClassErrorContentItem)
  37. return b
  38. }
  39. type ImplError struct {
  40. Concrete string
  41. Interface string
  42. Method string
  43. }
  44. func (e ImplError) Describe(problem string) richtext.Block {
  45. return makeErrorDescBlock (
  46. "type", e.Concrete, "cannot implement interface", e.Interface,
  47. ": method", e.Method, "not available:", problem,
  48. )
  49. }
  50. type SizeLimitError struct {
  51. Given uint
  52. Limit uint
  53. }
  54. func (e SizeLimitError) Describe(which string) richtext.Block {
  55. return makeErrorDescBlock (
  56. fmt.Sprintf("%s size limit exceeded (%d/%d)", which, e.Given, e.Limit),
  57. )
  58. }
  59. // ****************************************************************************
  60. type E_ModuleNotFound struct {
  61. ModuleName string
  62. }
  63. func (e E_ModuleNotFound) DescribeError() richtext.Block {
  64. return makeErrorDescBlock (
  65. "no such module: ", e.ModuleName,
  66. )
  67. }
  68. type E_BlankTypeDefinition struct {}
  69. func (E_BlankTypeDefinition) DescribeError() richtext.Block {
  70. return makeErrorDescBlock (
  71. "blank type definition",
  72. )
  73. }
  74. type E_DuplicateTypeDefinition struct {
  75. Which string
  76. }
  77. func (e E_DuplicateTypeDefinition) DescribeError() richtext.Block {
  78. return makeErrorDescBlock (
  79. "duplicate definition for type", e.Which,
  80. )
  81. }
  82. type E_InvalidMetadata struct {
  83. Reason string
  84. }
  85. func (e E_InvalidMetadata) DescribeError() richtext.Block {
  86. return makeErrorDescBlock (
  87. fmt.Sprintf("invalid metadata: %s", e.Reason),
  88. )
  89. }
  90. type E_InvalidTypeName struct {
  91. Name string
  92. }
  93. func (e E_InvalidTypeName) DescribeError() richtext.Block {
  94. return makeErrorDescBlock (
  95. fmt.Sprintf("invalid type name: %s", strconv.Quote(e.Name)),
  96. )
  97. }
  98. type E_TypeParametersOnCaseType struct {}
  99. func (E_TypeParametersOnCaseType) DescribeError() richtext.Block {
  100. return makeErrorDescBlock (
  101. "cannot specify explicit type parameters on case types",
  102. )
  103. }
  104. type E_TypeNotFound struct {
  105. Which string
  106. }
  107. func (e E_TypeNotFound) DescribeError() richtext.Block {
  108. return makeErrorDescBlock (
  109. "no such type:", e.Which,
  110. )
  111. }
  112. type E_TypeWrongParameterQuantity struct {
  113. Which string
  114. Given uint
  115. Least uint
  116. Total uint
  117. }
  118. func (e E_TypeWrongParameterQuantity) DescribeError() richtext.Block {
  119. var arity string
  120. if e.Least != e.Total {
  121. arity = fmt.Sprintf("total %d [at least %d]", e.Total, e.Least)
  122. } else {
  123. arity = fmt.Sprintf("total %d", e.Total)
  124. }
  125. var arity_note = fmt.Sprintf("(%s required but %d given)", arity, e.Given)
  126. return makeErrorDescBlock (
  127. "wrong parameter quantity for type", e.Which,
  128. arity_note,
  129. )
  130. }
  131. type E_TypeDuplicateField struct {
  132. Which string
  133. }
  134. func (e E_TypeDuplicateField) DescribeError() richtext.Block {
  135. return makeErrorDescBlock (
  136. "duplicate field:", e.Which,
  137. )
  138. }
  139. type E_DefaultValuesForNonRecordType struct {}
  140. func (E_DefaultValuesForNonRecordType) DescribeError() richtext.Block {
  141. return makeErrorDescBlock (
  142. "cannot define default field values for a non-record type",
  143. )
  144. }
  145. type E_CircularSubtypingDefinition struct {
  146. Which [] string
  147. }
  148. func (e E_CircularSubtypingDefinition) DescribeError() richtext.Block {
  149. var b = makeErrorDescBlankBlock()
  150. b.WriteSpan("circular subtyping definition:", richtext.TAG_ERR_NORMAL)
  151. b.WriteSpan("cycle(s) detected within types:", richtext.TAG_ERR_NORMAL)
  152. for i, t := range e.Which {
  153. if i > 0 {
  154. b.WriteSpan(",", richtext.TAG_ERR_NORMAL)
  155. }
  156. b.WriteSpan(t, richtext.TAG_ERR_INLINE)
  157. }
  158. return b
  159. }
  160. type E_CircularInterfaceDefinition struct {
  161. Which [] string
  162. }
  163. func (e E_CircularInterfaceDefinition) DescribeError() richtext.Block {
  164. var b = makeErrorDescBlankBlock()
  165. b.WriteSpan("circular interface definition:", richtext.TAG_ERR_NORMAL)
  166. b.WriteSpan("cycle(s) detected within types:", richtext.TAG_ERR_NORMAL)
  167. for i, t := range e.Which {
  168. if i > 0 {
  169. b.WriteSpan(",", richtext.TAG_ERR_NORMAL)
  170. }
  171. b.WriteSpan(t, richtext.TAG_ERR_INLINE)
  172. }
  173. return b
  174. }
  175. type E_DuplicateImplemented struct {
  176. Which string
  177. }
  178. func (e E_DuplicateImplemented) DescribeError() richtext.Block {
  179. return makeErrorDescBlock (
  180. "duplicated implemented type:", e.Which,
  181. )
  182. }
  183. type E_BadImplemented struct {
  184. Which string
  185. }
  186. func (e E_BadImplemented) DescribeError() richtext.Block {
  187. return makeErrorDescBlock (
  188. "bad implemented type:", e.Which,
  189. "(should be an interface type)",
  190. )
  191. }
  192. type E_BlankTypeExpr struct {}
  193. func (E_BlankTypeExpr) DescribeError() richtext.Block {
  194. return makeErrorDescBlock (
  195. "blank type expression",
  196. )
  197. }
  198. type E_TooManyTypeParameters struct {
  199. SizeLimitError
  200. }
  201. func (e E_TooManyTypeParameters) DescribeError() richtext.Block {
  202. return e.Describe("type parameter list")
  203. }
  204. type E_InvalidVarianceOnParameters struct {
  205. Which [] string
  206. }
  207. func (e E_InvalidVarianceOnParameters) DescribeError() richtext.Block {
  208. var b = makeErrorDescBlankBlock()
  209. b.WriteSpan("invalid variance declared on parameters:", richtext.TAG_ERR_NORMAL)
  210. for i, t := range e.Which {
  211. if i > 0 {
  212. b.WriteSpan(",", richtext.TAG_ERR_NORMAL)
  213. }
  214. b.WriteSpan(t, richtext.TAG_ERR_INLINE)
  215. }
  216. return b
  217. }
  218. type E_TooManyImplemented struct {
  219. SizeLimitError
  220. }
  221. func (e E_TooManyImplemented) DescribeError() richtext.Block {
  222. return e.Describe("implemented type list")
  223. }
  224. type E_ImplementedIncompatibleParameters struct {
  225. TypeName string
  226. InterfaceName string
  227. }
  228. func (e E_ImplementedIncompatibleParameters) DescribeError() richtext.Block {
  229. return makeErrorDescBlock (
  230. "type", e.TypeName,
  231. "cannot implement the interface", e.InterfaceName,
  232. "(parameters incompatible)",
  233. )
  234. }
  235. type E_InvalidFunctionName struct {
  236. Name string
  237. }
  238. func (e E_InvalidFunctionName) DescribeError() richtext.Block {
  239. return makeErrorDescBlock (
  240. fmt.Sprintf("invalid function name: %s", strconv.Quote(e.Name)),
  241. )
  242. }
  243. type E_ImplMethodNoSuchFunctionOrField struct {
  244. ImplError
  245. }
  246. func (e E_ImplMethodNoSuchFunctionOrField) DescribeError() richtext.Block {
  247. return e.Describe("no such function or field")
  248. }
  249. type E_ImplMethodNoneCompatible struct {
  250. ImplError
  251. }
  252. func (e E_ImplMethodNoneCompatible) DescribeError() richtext.Block {
  253. return e.Describe("none of method functions compatible")
  254. }
  255. type E_ImplMethodAmbiguous struct {
  256. ImplError
  257. }
  258. func (e E_ImplMethodAmbiguous) DescribeError() richtext.Block {
  259. return e.Describe(
  260. "ambiguous method implementation: " +
  261. "corresponding field and method function both exist",
  262. )
  263. }
  264. type E_ImplMethodDuplicateCompatible struct {
  265. ImplError
  266. }
  267. func (e E_ImplMethodDuplicateCompatible) DescribeError() richtext.Block {
  268. return e.Describe("multiple method functions compatible")
  269. }
  270. type E_ReceiverTypeNotFound struct {
  271. TypeName string
  272. }
  273. func (e E_ReceiverTypeNotFound) DescribeError() richtext.Block {
  274. return makeErrorDescBlock (
  275. "bad receiver: no such type: ", e.TypeName,
  276. )
  277. }
  278. type E_IntegerNotRepresentableByFloatType struct {}
  279. func (E_IntegerNotRepresentableByFloatType) DescribeError() richtext.Block {
  280. return makeErrorDescBlock (
  281. "integer literal is too big to be represented " +
  282. "using a floating-point type",
  283. )
  284. }
  285. type E_IntegerOverflowUnderflow struct {
  286. TypeName string
  287. }
  288. func (e E_IntegerOverflowUnderflow) DescribeError() richtext.Block {
  289. return makeErrorDescBlock (
  290. "integer literal is not representable by the type", e.TypeName,
  291. )
  292. }
  293. type E_FloatOverflowUnderflow struct {}
  294. func (E_FloatOverflowUnderflow) DescribeError() richtext.Block {
  295. return makeErrorDescBlock("float literal value too big")
  296. }
  297. type E_InvalidChar struct {
  298. Content string
  299. }
  300. func (e E_InvalidChar) DescribeError() richtext.Block {
  301. return makeErrorDescBlock (
  302. "invalid character", e.Content,
  303. )
  304. }
  305. type E_NotAssignable struct {
  306. From string
  307. To string
  308. }
  309. func (e E_NotAssignable) DescribeError() richtext.Block {
  310. return makeErrorDescBlock (
  311. "type", e.From,
  312. "cannot be assigned to the type", e.To,
  313. )
  314. }
  315. type E_TupleSizeNotMatching struct {
  316. Required uint
  317. Given uint
  318. }
  319. func (e E_TupleSizeNotMatching) DescribeError() richtext.Block {
  320. return makeErrorDescBlock (
  321. "tuple size not matching: " +
  322. fmt.Sprintf("%d required but %d given", e.Required, e.Given),
  323. )
  324. }
  325. type E_TupleUnexpectedParallelMark struct {}
  326. func (E_TupleUnexpectedParallelMark) DescribeError() richtext.Block {
  327. return makeErrorDescBlock (
  328. "unexpected parallel mark",
  329. )
  330. }
  331. type E_CannotMatchUnit struct {
  332. TypeName string
  333. }
  334. func (e E_CannotMatchUnit) DescribeError() richtext.Block {
  335. return makeErrorDescBlock (
  336. "cannot match unit from type", e.TypeName,
  337. )
  338. }
  339. type E_CannotMatchTuple struct {
  340. TypeName string
  341. }
  342. func (e E_CannotMatchTuple) DescribeError() richtext.Block {
  343. return makeErrorDescBlock (
  344. "cannot match tuple from type", e.TypeName,
  345. )
  346. }
  347. type E_CannotMatchRecord struct {
  348. TypeName string
  349. }
  350. func (e E_CannotMatchRecord) DescribeError() richtext.Block {
  351. return makeErrorDescBlock (
  352. "cannot match record from type", e.TypeName,
  353. )
  354. }
  355. type E_PatternSizeLimitExceeded struct {}
  356. func (E_PatternSizeLimitExceeded) DescribeError() richtext.Block {
  357. return makeErrorDescBlock (
  358. "too many bindings in pattern",
  359. "(binding quantity limit for one pattern exceeded limit)",
  360. )
  361. }
  362. type E_DuplicateBinding struct {
  363. BindingName string
  364. }
  365. func (e E_DuplicateBinding) DescribeError() richtext.Block {
  366. return makeErrorDescBlock (
  367. "duplicate binding", e.BindingName,
  368. )
  369. }
  370. type E_FieldNotFound struct {
  371. FieldName string
  372. TypeName string
  373. }
  374. func (e E_FieldNotFound) DescribeError() richtext.Block {
  375. return makeErrorDescBlock (
  376. "field", e.FieldName,
  377. "does not exist in type", e.TypeName,
  378. )
  379. }
  380. type E_MissingField struct {
  381. FieldName string
  382. }
  383. func (e E_MissingField) DescribeError() richtext.Block {
  384. return makeErrorDescBlock (
  385. "missing field", e.FieldName,
  386. )
  387. }
  388. type E_ExplicitTypeRequired struct {}
  389. func (E_ExplicitTypeRequired) DescribeError() richtext.Block {
  390. return makeErrorDescBlock("explicit type cast expected")
  391. }
  392. type E_LambdaAssignedToIncompatible struct {
  393. TypeName string
  394. }
  395. func (e E_LambdaAssignedToIncompatible) DescribeError() richtext.Block {
  396. return makeErrorDescBlock (
  397. "lambda cannot be assigned to incompatible type", e.TypeName,
  398. )
  399. }
  400. type E_TooManyTupleElements struct {
  401. SizeLimitError
  402. }
  403. func (e E_TooManyTupleElements) DescribeError() richtext.Block {
  404. return e.Describe("tuple")
  405. }
  406. type E_TooManyFormatterInputs struct {
  407. SizeLimitError
  408. }
  409. func (e E_TooManyFormatterInputs) DescribeError() richtext.Block {
  410. return e.Describe("string formatter input")
  411. }
  412. type E_TooManyRecordFields struct {
  413. SizeLimitError
  414. }
  415. func (e E_TooManyRecordFields) DescribeError() richtext.Block {
  416. return e.Describe("record")
  417. }
  418. type E_TooManyEnumCases struct {
  419. SizeLimitError
  420. }
  421. func (e E_TooManyEnumCases) DescribeError() richtext.Block {
  422. return e.Describe("enum")
  423. }
  424. type E_TooManyInterfaceMethods struct {
  425. SizeLimitError
  426. }
  427. func (e E_TooManyInterfaceMethods) DescribeError() richtext.Block {
  428. return e.Describe("interface")
  429. }
  430. type E_DuplicateField struct {
  431. FieldName string
  432. }
  433. func (e E_DuplicateField) DescribeError() richtext.Block {
  434. return makeErrorDescBlock (
  435. "duplicate field", e.FieldName,
  436. )
  437. }
  438. type E_UpdateOnNonRecord struct {
  439. TypeName string
  440. }
  441. func (e E_UpdateOnNonRecord) DescribeError() richtext.Block {
  442. return makeErrorDescBlock (
  443. "cannot perform update operation on non-record type", e.TypeName,
  444. )
  445. }
  446. type E_NoSuchFieldOrMethod struct {
  447. FieldName string
  448. TypeName string
  449. }
  450. func (e E_NoSuchFieldOrMethod) DescribeError() richtext.Block {
  451. return makeErrorDescBlock (
  452. "field or method", e.FieldName,
  453. "does not exist on type", e.TypeName)
  454. }
  455. type E_NoSuchFieldOrCase struct {
  456. FieldName string
  457. TypeName string
  458. }
  459. func (e E_NoSuchFieldOrCase) DescribeError() richtext.Block {
  460. return makeErrorDescBlock (
  461. "field or case", e.FieldName,
  462. "does not exist on type", e.TypeName)
  463. }
  464. type E_RecordSizeNotMatching struct {
  465. Given uint
  466. Required uint
  467. }
  468. func (e E_RecordSizeNotMatching) DescribeError() richtext.Block {
  469. return makeErrorDescBlock (
  470. "record size not matching: " +
  471. fmt.Sprintf("%d required but %d given", e.Required, e.Given),
  472. )
  473. }
  474. type E_TypeNotCallable struct {
  475. TypeName string
  476. }
  477. func (e E_TypeNotCallable) DescribeError() richtext.Block {
  478. return makeErrorDescBlock (
  479. "type", e.TypeName,
  480. "is not callable",
  481. )
  482. }
  483. type E_NonLambdaRecursive struct {}
  484. func (E_NonLambdaRecursive) DescribeError() richtext.Block {
  485. return makeErrorDescBlock (
  486. "non-lambda expression cannot be declared recursive",
  487. )
  488. }
  489. type E_NoSuchBindingOrFunction struct {
  490. Name string
  491. Pivot string
  492. }
  493. func (e E_NoSuchBindingOrFunction) DescribeError() richtext.Block {
  494. if e.Pivot == "" {
  495. return makeErrorDescBlock (
  496. "no such binding or function: ", e.Name,
  497. )
  498. } else {
  499. return makeErrorDescBlock (
  500. "no such binding or function: ", e.Name,
  501. fmt.Sprintf("(in the module of the type %s)", e.Pivot),
  502. )
  503. }
  504. }
  505. type E_ImplicitContextNotFound struct {
  506. InnerError richtext.Block
  507. }
  508. func (e E_ImplicitContextNotFound) DescribeError() richtext.Block {
  509. var b = makeErrorDescBlankBlock()
  510. b.WriteSpan("implicit context not available: ", richtext.TAG_ERR_NORMAL)
  511. b.Append(e.InnerError)
  512. return b
  513. }
  514. type E_InvalidFunctionUsage struct {
  515. Candidates [] OverloadCandidateInfo
  516. }
  517. type OverloadCandidateInfo struct {
  518. Name string
  519. Signature string
  520. Error *source.Error
  521. }
  522. func (e E_InvalidFunctionUsage) DescribeError() richtext.Block {
  523. var b = makeErrorDescBlankBlock()
  524. b.WriteLine(
  525. "none of functions can be called/assigned:",
  526. richtext.TAG_ERR_NORMAL)
  527. for _, candidate := range e.Candidates {
  528. var item = makeEmptyErrorContentItemBlock()
  529. var title = fmt.Sprintf("%s: %s", candidate.Name, candidate.Signature)
  530. item.WriteLine(title, richtext.TAG_ERR_NOTE)
  531. item.Append(candidate.Error.Message())
  532. b.Append(item)
  533. }
  534. return b
  535. }
  536. type E_AmbiguousFunctionUsage struct {
  537. Options [] OverloadOptionInfo
  538. }
  539. type OverloadOptionInfo struct {
  540. Name string
  541. Signature string
  542. }
  543. func (e E_AmbiguousFunctionUsage) DescribeError() richtext.Block {
  544. var b = makeErrorDescBlankBlock()
  545. b.WriteLine(
  546. "callee/assignee not decidable within functions:",
  547. richtext.TAG_ERR_NORMAL)
  548. for _, option := range e.Options {
  549. var item = makeEmptyErrorContentItemBlock()
  550. var item_text = fmt.Sprintf("%s: %s", option.Name, option.Signature)
  551. item.WriteLine(item_text, richtext.TAG_ERR_NOTE)
  552. b.Append(item)
  553. }
  554. return b
  555. }
  556. type E_TypeParametersOnLocalBindingRef struct {}
  557. func (E_TypeParametersOnLocalBindingRef) DescribeError() richtext.Block {
  558. return makeErrorDescBlock (
  559. "cannot specify type parameters on a local binding reference",
  560. )
  561. }
  562. type E_TypeParametersExceededArity struct {
  563. Arity uint
  564. }
  565. func (e E_TypeParametersExceededArity) DescribeError() richtext.Block {
  566. return makeErrorDescBlock (
  567. "the quantity of specified type parameters exceeded " +
  568. fmt.Sprintf("the arity (%d)", e.Arity),
  569. )
  570. }
  571. type E_InvalidTypeParameter struct {
  572. Index uint
  573. Name string
  574. }
  575. func (e E_InvalidTypeParameter) DescribeError() richtext.Block {
  576. return makeErrorDescBlock (
  577. "invalid type specified for type parameter",
  578. fmt.Sprintf("%s (#%d)", e.Name, e.Index),
  579. )
  580. }
  581. type E_TypeParameterNotInferred struct {
  582. Index uint
  583. Name string
  584. }
  585. func (e E_TypeParameterNotInferred) DescribeError() richtext.Block {
  586. return makeErrorDescBlock (
  587. "type parameter", fmt.Sprintf("%s (#%d)", e.Name, e.Index),
  588. "cannot be automatically inferred",
  589. "(explicit type parameters required)",
  590. )
  591. }
  592. type E_SwitchOnNonEnum struct {}
  593. func (E_SwitchOnNonEnum) DescribeError() richtext.Block {
  594. return makeErrorDescBlock (
  595. "cannot switch on a non-enum value",
  596. )
  597. }
  598. type E_DuplicateCase struct {}
  599. func (E_DuplicateCase) DescribeError() richtext.Block {
  600. return makeErrorDescBlock (
  601. "duplicate case",
  602. )
  603. }
  604. type E_NoSuchCase struct {
  605. Case string
  606. }
  607. func (e E_NoSuchCase) DescribeError() richtext.Block {
  608. return makeErrorDescBlock (
  609. "no such case:", e.Case,
  610. )
  611. }
  612. type E_CondNotExhaustive struct {}
  613. func (E_CondNotExhaustive) DescribeError() richtext.Block {
  614. return makeErrorDescBlock (
  615. "conditional branches not exhaustive",
  616. )
  617. }
  618. type E_SelectTooManyArguments struct {}
  619. func (E_SelectTooManyArguments) DescribeError() richtext.Block {
  620. return makeErrorDescBlock (
  621. "too many arguments for a select expression",
  622. )
  623. }
  624. type E_SelectInsufficientArguments struct {}
  625. func (E_SelectInsufficientArguments) DescribeError() richtext.Block {
  626. return makeErrorDescBlock (
  627. "argument quantity not enough for a select expression",
  628. )
  629. }
  630. type E_SelectOverlappingBranches struct {}
  631. func (E_SelectOverlappingBranches) DescribeError() richtext.Block {
  632. return makeErrorDescBlock (
  633. "overlapping branches detected")
  634. }
  635. type E_RedundantTypeParameters struct {}
  636. func (E_RedundantTypeParameters) DescribeError() richtext.Block {
  637. return makeErrorDescBlock (
  638. "redundant type parameters",
  639. )
  640. }
  641. type E_BoxIntoProtected struct {
  642. TypeName string
  643. CtxModName string
  644. }
  645. func (e E_BoxIntoProtected) DescribeError() richtext.Block {
  646. return makeErrorDescBlock (
  647. "cannot box a value into the protected box type", e.TypeName,
  648. "under the context of module", e.CtxModName,
  649. )
  650. }
  651. type E_BoxIntoOpaque struct {
  652. TypeName string
  653. CtxModName string
  654. }
  655. func (e E_BoxIntoOpaque) DescribeError() richtext.Block {
  656. return makeErrorDescBlock (
  657. "cannot box a value into the opaque box type", e.TypeName,
  658. "under the context of module", e.CtxModName,
  659. )
  660. }
  661. type E_InvalidConstructorCall struct {}
  662. func (E_InvalidConstructorCall) DescribeError() richtext.Block {
  663. return makeErrorDescBlock (
  664. "invalid constructor call",
  665. )
  666. }
  667. type E_InvalidConstructor struct {}
  668. func (E_InvalidConstructor) DescribeError() richtext.Block {
  669. return makeErrorDescBlock (
  670. "invalid constructor",
  671. )
  672. }
  673. type E_NotImplementation struct {
  674. Type string
  675. Interface string
  676. }
  677. func (e E_NotImplementation) DescribeError() richtext.Block {
  678. return makeErrorDescBlock (
  679. "type", e.Type,
  680. "is not an implementation of the interface", e.Interface,
  681. )
  682. }
  683. type E_DynamicCastFromNonInterface struct {
  684. Type string
  685. }
  686. func (e E_DynamicCastFromNonInterface) DescribeError() richtext.Block {
  687. return makeErrorDescBlock (
  688. "cannot dynamically cast from non-interface type",
  689. e.Type,
  690. )
  691. }
  692. type E_DynamicCastToInterface struct {}
  693. func (E_DynamicCastToInterface) DescribeError() richtext.Block {
  694. return makeErrorDescBlock (
  695. "cannot dynamically cast to interface type: unsupported feature",
  696. )
  697. }
  698. type E_BlankTerm struct {}
  699. func (E_BlankTerm) DescribeError() richtext.Block {
  700. return makeErrorDescBlock (
  701. "expression expected",
  702. )
  703. }
  704. type E_NotSerializable struct {
  705. TypeName string
  706. }
  707. func (e E_NotSerializable) DescribeError() richtext.Block {
  708. return makeErrorDescBlock (
  709. "type", e.TypeName,
  710. "is not serializable",
  711. )
  712. }
  713. type E_DuplicateVdTypeId struct {
  714. Id string
  715. }
  716. func (e E_DuplicateVdTypeId) DescribeError() richtext.Block {
  717. return makeErrorDescBlock (
  718. "duplicate assignment of type id", e.Id,
  719. )
  720. }
  721. type E_GenericTypeDeclaredSerializable struct {
  722. TypeDefName string
  723. }
  724. func (e E_GenericTypeDeclaredSerializable) DescribeError() richtext.Block {
  725. return makeErrorDescBlock (
  726. "type", e.TypeDefName,
  727. "cannot be serializable",
  728. "(interface and native type cannot be declared serializable)",
  729. )
  730. }
  731. type E_EnumCaseNotSerializable struct {
  732. Case string
  733. }
  734. func (e E_EnumCaseNotSerializable) DescribeError() richtext.Block {
  735. return makeErrorDescBlock (
  736. "case", e.Case,
  737. "must be declared serializable for the enum to be serializable",
  738. )
  739. }
  740. type E_InvalidValidator struct {}
  741. func (E_InvalidValidator) DescribeError() richtext.Block {
  742. return makeErrorDescBlock (
  743. "invalid validator",
  744. )
  745. }
  746. type E_DuplicateValidator struct {}
  747. func (E_DuplicateValidator) DescribeError() richtext.Block {
  748. return makeErrorDescBlock (
  749. "duplicate validator",
  750. )
  751. }
  752. type E_InvalidAdapter struct {}
  753. func (E_InvalidAdapter) DescribeError() richtext.Block {
  754. return makeErrorDescBlock (
  755. "invalid adapter",
  756. )
  757. }
  758. type E_DuplicateAdapter struct {}
  759. func (E_DuplicateAdapter) DescribeError() richtext.Block {
  760. return makeErrorDescBlock (
  761. "duplicate adapter",
  762. )
  763. }
  764. type E_MissingValidator struct {
  765. TypeDefName string
  766. }
  767. func (e E_MissingValidator) DescribeError() richtext.Block {
  768. return makeErrorDescBlock (
  769. "missing validator for type", e.TypeDefName,
  770. )
  771. }
  772. type E_DuplicateServiceIdentifier struct {
  773. ServiceIdentifier string
  774. }
  775. func (e E_DuplicateServiceIdentifier) DescribeError() richtext.Block {
  776. return makeErrorDescBlock (
  777. "duplicate assignment of service id", e.ServiceIdentifier,
  778. )
  779. }
  780. type E_ServiceNotInterface struct {}
  781. func (E_ServiceNotInterface) DescribeError() richtext.Block {
  782. return makeErrorDescBlock (
  783. "a service type must be an interface type",
  784. )
  785. }
  786. type E_GenericService struct {}
  787. func (E_GenericService) DescribeError() richtext.Block {
  788. return makeErrorDescBlock (
  789. "a service interface type cannot be generic",
  790. )
  791. }
  792. type E_ServiceWithBaseInterface struct {}
  793. func (e E_ServiceWithBaseInterface) DescribeError() richtext.Block {
  794. return makeErrorDescBlock (
  795. "a service interface type cannot have base interfaces",
  796. )
  797. }
  798. type E_ServiceInvalidMethodType struct {
  799. TypeName string
  800. }
  801. func (e E_ServiceInvalidMethodType) DescribeError() richtext.Block {
  802. return makeErrorDescBlock (
  803. "invalid service method type", e.TypeName,
  804. "(output should be Observable[DATA,Error] or Async[DATA,Error])",
  805. )
  806. }
  807. type E_ServiceMissingConstructorArgumentType struct {
  808. TypeDefName string
  809. }
  810. func (e E_ServiceMissingConstructorArgumentType) DescribeError() richtext.Block {
  811. return makeErrorDescBlock (
  812. "missing corresponding constructor argument type for the service type",
  813. e.TypeDefName,
  814. )
  815. }
  816. type E_ServiceDuplicateConstructor struct {
  817. TypeDefName string
  818. }
  819. func (e E_ServiceDuplicateConstructor) DescribeError() richtext.Block {
  820. return makeErrorDescBlock (
  821. "duplicate service constructor for type", e.TypeDefName,
  822. )
  823. }
  824. type E_SelfRefBindingOnTopLevel struct {}
  825. func (E_SelfRefBindingOnTopLevel) DescribeError() richtext.Block {
  826. return makeErrorDescBlock (
  827. "self-reference binding is NOT supported on top-level functions",
  828. )
  829. }
  830. type E_InvalidAsset struct {
  831. Error error
  832. }
  833. func (e E_InvalidAsset) DescribeError() richtext.Block {
  834. return makeErrorDescBlock (
  835. fmt.Sprintf("invalid asset: %s", e.Error.Error()),
  836. )
  837. }
  838. type E_WrongAssetType struct {
  839. Extension string
  840. Required string
  841. }
  842. func (e E_WrongAssetType) DescribeError() richtext.Block {
  843. return makeErrorDescBlock (
  844. fmt.Sprintf("type for [%s] asset should be", e.Extension),
  845. e.Required,
  846. )
  847. }
  848. type E_DuplicateEntryEffect struct {}
  849. func (E_DuplicateEntryEffect) DescribeError() richtext.Block {
  850. return makeErrorDescBlock (
  851. "duplicate entry effect",
  852. )
  853. }