Error codes

E0415: conversion to any Shape exceeds the shape method's effects

In a terminal: auk explain E0415 prints this page.

On this page

A value converted to any Shape is called through the shape's methods, which declare what effects they may use. Here the type's method uses more than the shape declares, so calling it through the shape would hide an effect.

Wrong#

auk
shape Log { fn log(self, s: str) }
struct F { p: str }
fn log(f: F, s: str) uses fs { fs.write(f.p, s) else () }
fn report(l: any Log) { l.log("hi") }
fn main() { report(F { p: "a" }) }

Fixed#

auk
shape Log { fn log(self, s: str) uses fs }
struct F { p: str }
fn log(f: F, s: str) uses fs { fs.write(f.p, s) else () }
fn report(l: any Log) uses fs { l.log("hi") }
fn main() uses fs { report(F { p: "a" }) }

Common causes#

  • A shape method declared without the effects its implementations need.
  • An implementation that does I/O where the shape promises purity.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page