Skip to content

internal error: inconsistent environment type #18103

@foldl

Description

@foldl

Compiler or VM crashed on this example .

Playground: https://play.nim-lang.org/#ix=3nUW

Example

import base64, complex, sequtils, math, sugar

type

    FP = float
    T = object
        index: int
        arg: FP
        val: Complex[FP]
    M = object
        alpha, beta: FP

func a(s: openArray[T], model: M): seq[T] =
    let f = (tn: int) => model.alpha + FP(tn) * model.beta;
    return mapIt s:
        block:
            let s  = it.val * rect(1.0, - f(it.index))
            T(index: it.index, arg: phase(s), val: s)

proc b(): float64 =
    var s = toSeq(0..10).mapIt(T(index: it, arg: 1.0, val: complex.complex(1.0)))
    discard a(s, M(alpha: 1, beta: 1))
    return 1.0

func cc(str: cstring, offset: ptr[cdouble]): cint {.exportc.} =
    offset[] = b()
    return 0

static:
    echo b()

Current Output

Error: internal error: inconsistent environment type

Expected Output

The program should be compiled successfully.

Additional Information

From 1.4.0 to 1.4.8, all have this problem.

$ nim -v
Nim Compiler Version 1.4.8 [Windows: i386]
Compiled at 2021-05-25
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions