Skip to content

Sequtils bug: cannot attach a custom pragma to 's2' #18113

@narimiran

Description

@narimiran

A combination of pragma + toSeq + filterIt causes this.

Example

import sequtils

{.push raises: [Defect].}

var a = toSeq([1, 2, 10, 20]).filterIt(it > 5)

Current Output

sequtils.nim(738, 18) Error: cannot attach a custom pragma to 's2'

Possible Solution

Several walkarounds:

import sequtils

# {.push raises: [Defect].}         <--- commenting out this line

var a = toSeq([1, 2, 10, 20]).filterIt(it > 5)
import sequtils

{.push raises: [Defect].}

var a = toSeq([1, 2, 10, 20])     # <--- doing toSeq and filterIt separately
var b = a.filterIt(it > 5)

Additional Information

This is a regression, and git bisects says it is caused by this PR: #17448. cc @saem

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-05-27
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 1e0165186bb8539cfd8aca1a7af8d01dc278bd46
active boot switches: -d:release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions