UNPKG

@sap/cds-compiler

Version:

CDS (Core Data Services) compiler and backends

46 lines (34 loc) 1.29 kB
# anno-missing-rewrite A propagated annotation containing expressions can't be rewritten and would end up with invalid paths. While propagating annotations containing expressions such as `@anno: (path)`, the compiler ensures that the path remains valid. If necessary, the paths have to be rewritten, e.g. when being propagated to projections that rename their source's elements. If rewriting is not possible, this error is emitted. ## Example Erroneous code example: ```cds type T : { @anno: (sibling) elem: String; sibling: String; }; type TString : T:elem; // ❌ there is no `sibling` ``` The annotating `@anno` would be propagated to `TString`. However, because its path refers to an element that is not reachable at `TString`, the path can't be rewritten and compilation fails. ## How to Fix Explicitly override the annotation. Either remove it by setting its value to `null` or by using another value. ```cds // (1) direct annotation @anno: null type TString : T:elem; // (2) annotate statement type TString : T:elem; annotate TString with @(anno: null); ``` Variant (1) may not always be applicable, e.g. if annotations in a structured type would need to be overridden. In those cases, use variant (2) and assign annotations via the `annotate` statement.