Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type deduction causes formula CT error #29

Open
Vindaar opened this issue May 19, 2022 · 2 comments
Open

Type deduction causes formula CT error #29

Vindaar opened this issue May 19, 2022 · 2 comments

Comments

@Vindaar
Copy link
Member

Vindaar commented May 19, 2022

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... :)

@Vindaar
Copy link
Member Author

Vindaar commented Dec 2, 2022

The special case for bool types has been addressed in #46, but there are probably other cases that need attention.

@Vindaar
Copy link
Member Author

Vindaar commented Dec 13, 2022

Note: the code snippet in the issue works nowadays. I need to check the code again to see if should in theory work in general cases now and if so close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant