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

Example code can't compile #11

Open
cpunion opened this issue Nov 2, 2022 · 4 comments
Open

Example code can't compile #11

cpunion opened this issue Nov 2, 2022 · 4 comments

Comments

@cpunion
Copy link

cpunion commented Nov 2, 2022

Test code below copied from README.md :

import db_sqlite, gatabase

let db = open(":memory:", "", "", "")
db.exec(sql"""
  create table if not exists person(
    id      integer     primary key,
    name    varchar(9)  not null unique,
    active  bool        not null default true,
    rank    float       not null default 0.0
  ); """)

exec [42, "Pepe", true, 9.6]:
  insertinto "person"
  values 4

let row = [].getRow:
  select '*'
  `from` "person"

echo row

It compiles fail:

$ nim c -r test.nim
test.nim(12, 11) Error: type mismatch: got 'string' for '"Pepe"' but expected 'int literal(42)'

$ nim -v
Nim Compiler Version 1.6.8 [MacOSX: arm64]
Compiled at 2022-09-27
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release -d:nimUseLinenoise
@cpunion
Copy link
Author

cpunion commented Nov 6, 2022

Splitted template exec to two definitions:

template exec*(args: varargs[string, `$`]; inner: untyped)

template exec*(args: seq[string]; inner: untyped)

It works.

@juancarlospaco
Copy link
Owner

Pull Request welcome.

@cpunion
Copy link
Author

cpunion commented Nov 6, 2022

@juancarlospaco So what is the reason? Does the Nim compiler has a break change?

I'm not sure it's a good way, too many template methods need to change.

image

@juancarlospaco
Copy link
Owner

I am kinda waiting for Nim 2.0 to re-check everything one-by-one, because it may bring improvements in multiple places,
but if you need it urgently then feel free to send Pull Request.

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

2 participants