On this page
B1012: operator of a type is not visible
Catalog status: active. Default severity: error. Stable name: operator-not-visible. Family: Names and declarations.
The predefined operators of a type are declared, like the type, in the package that declares it. Outside that package they are visible only through a use clause (Ada RM 8.4), so D + 5 with D : Units.Meters needs use type Units.Meters; (or use Units;).
Example (Vada)
with Units;
procedure Main is
D : Units.Meters := 10;
begin
D := D + 5;
end Main;Example (Varc)
import Units;
fn main() {
var d: Units.Meters = 10;
d = d + 5;
}
What to do (Vada)
Add use type Units.Meters; (the fix-it puts it before the unit), or write Units."+" (D, 5).
What to do (Varc)
Add use type Units.Meters; (the fix-it puts it before the unit), or use Units;.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See names and declarations, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.