Skip to content

Type deduction causes formula CT error #29

Open
@Vindaar

Description

@Vindaar

Reported by KosKosynsky on the #science channel (added steps for a minimal repro):

import datamancer, strutils

var flota = toDf({"x" : @["a", "b"], "y" : @["1", "2"], "z" : @[1, 3]})
let flota_cols = flota.getKeys()
for i_col in flota_cols:
  if (flota[i_col].nativeColKind == colString):
    flota = flota.mutate(f{string -> string: i_col ~ strip(idx(i_col))})

echo flota

which fails in the determineTypeFromProc helper, which tries to look at the default arguments for type info from the latest argument to strip (we shouldn't even have to look at that, but in any case shouldn't fail!).

The issue is that we assume that the last field of a default nnkIdentDefs is a symbol, but it's not in this case. The offending node is:

IdentDefs
  Sym "leading"
  Empty
  Ident "true" 

from the params sequence:

  IdentDefs
    Sym "s"
    Sym "string"
    Empty
  IdentDefs
    Sym "leading"
    Empty
    Ident "true"
  IdentDefs
    Sym "trailing"
    Empty
    Ident "true"
  IdentDefs
    Sym "chars"
    BracketExpr
      Sym "set"
      Sym "char"
    Ident "Whitespace"

Instead of

        typ = pArg[pArg.len - 1].getType # use the default values type

we should check if the node is a type first before calling getType.

Question: what to do for idents?

Just find a way to fix it... :)

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