motoko icon indicating copy to clipboard operation
motoko copied to clipboard

BUG: unexpected cannot infer type of forward variable

Open crusso opened this issue 1 year ago • 1 comments

import { debugPrint; principalOfActor } = "mo:⛔";

actor class C() = Self {
    debugPrint "So far so good!" 
}

produces

type error [M0055], cannot infer type of forward variable debugPrint

I think its happening because of the special treatment of the last declaration in a block, that determines its return type.

But it's odd that we don't consider the type of imported identifiers to be known (they should be I think).

crusso avatar Oct 15 '24 14:10 crusso

Faced this issue right now:

import D "mo:dur";
import {dur} "mo:dur";

actor class Main() = this {
	let DELAY = D.dur("1m"); // ok
	let DELAY2 = dur("1m"); // type error [M0055], cannot infer type of forward variable dur

ZenVoich avatar Aug 06 '25 12:08 ZenVoich