Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0703: Import requires string literal

CodeCategoryStability
E0703IntrinsicPermanent

Explanation

@import requires its module specifier to appear directly as a string literal. Rue resolves the source graph before general expression evaluation, so a variable or computed string cannot select a module.

Likely cause

The import path was stored in a local or constant, constructed by an expression, or supplied as a non-string value instead of being written literally inside @import(...).

Examples

Import through a string variable

// --- main.rue
fn main() -> i32 {
    let path = "helper.rue";
    let helper = @import(path);
    helper.answer()
}

Write the import path as a literal

// --- main.rue
const helper = @import("helper.rue");
fn main() -> i32 { helper.answer() }
// --- helper.rue
pub fn answer() -> i32 { 42 }

References