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

TaintedString seems to be ignored in loops #406

Closed
gradha opened this issue Apr 27, 2013 · 2 comments
Closed

TaintedString seems to be ignored in loops #406

gradha opened this issue Apr 27, 2013 · 2 comments

Comments

@gradha
Copy link
Contributor

gradha commented Apr 27, 2013

The following example compiles and runs:

import unicode

proc test() =
  let input = readFile("weird.nim")
  for letter in runes(input):
    echo int(letter)

when 1 > 2:
  proc failtest() =
    let
      input = readFile("weird.nim")
      letters = runes(input)
    for letter in letters:
      echo int(letter)

when isMainModule:
  test()

However, changing the when condition to true makes the compiler display the error:

weird.nim(12, 22) Error: type mismatch: got (TaintedString)
but expected one of: 
unicode.runes(s: string): TRune

This is unexpected, why does the compiler catch the TaintedString being passed to the iterator in the let block but not in the for block? Shouldn't the compiler fail in the first case too forcing an explicit conversion from TaintedString to string?

@gradha
Copy link
Contributor Author

gradha commented Apr 27, 2013

The TaintedString error is misleading, actual tainted mode has to be turned on through a compiler switch. The problem here is that the runes iterator can't be assigned in a let block, the user needs to import sequtils and use toSeq on it. It would be nice if the compiler could display a more informative error, like "Can't assign iterator result in let block" or something similar which would point users directly to the problem. Maybe even suggest to import sequtils since toSeq is not available in the system module.

@Araq
Copy link
Member

Araq commented Dec 26, 2014

The error message is fine. With --taintedMode:on and 'letters = runes(input.string)' it produces the same error message as with --taintMode:off.

@Araq Araq closed this as completed Dec 26, 2014
Clyybber pushed a commit to Clyybber/Nim that referenced this issue Nov 7, 2022
…nim-lang#401 nim-lang#402 nim-lang#403 nim-lang#405 nim-lang#406 nim-lang#407 nim-lang#409 nim-lang#410 nim-lang#411 nim-lang#412 nim-lang#413

392: internal: remove sons from leaf nodes empty/none r=disruptek a=saem

## Summary
- pulls nkEmpty and nkNone into a branch without sons
- ensures more correctness by design

## Details
- various small fixes to get bootstrap working
- no tests failed, so that's a good{?} sign



395: stdlib: remove deprecated modules r=disruptek a=saem

deprecated stdlib module removal:
- removed events, LockFreeHash, parseopt2, and securehash
- associated clean-up in testament
- lib/deprecate/pure now only contains ospaths, an include for os
- remove events related tests

396: lang: remove deprecated c/C octal prefix r=disruptek a=saem

## Summary
- can no longer use 0c1
- this has long since been deprecated and not referenced in the manual


397: macros: remove deprecated TNimSym/TypeKinds r=disruptek a=saem

## Summary
- Removed macros.TNimSym and macros.TypeKinds

## Details
They are not used anywhere in the code base

399: dialect: remove old case object define r=disruptek a=saem

## Summary
- removed old case object define

NB reset magic is still present


401: stdlib: httpcore ==(string, HttpCode):bool removed r=disruptek a=saem

dropped proc from stdlib, it been deprecatd forever

402: stdlib: removed deprecated module oswalkdir r=disruptek a=saem

functionality has long since been moved to `std/os`

403: stdlib: times, remove deprecated procs r=disruptek a=saem

Removed deprecated constructors and setters for `times.DateTime`

Updated associated broken tests.

405: stdlib: remove deprecated os.existsFile/Dir r=disruptek a=saem

fileExists/dirExists are already present

406: pragma: remove the deprecated unroll pragma r=disruptek a=saem

supposedly it was ignored by the compiler, the fewer pragmas the better.

407: strutils: remove deprecated delete proc r=disruptek a=saem

## Summary

- remove deprecated `delete(var string, int, int)`
- removed associated tests
- updated usage of removed proc in rstgen

409: sequtils: remove deprecated delete proc r=disruptek a=saem

remove deprecated `delete[T](var T, int, int)` and its tests

410: algorithm: remove deprecated reversed proc r=disruptek a=saem

## Summary

- remove deprecated `reversed[T](var openArray[T], int, int): seq[T]`
- removed associated tests


411: math: renamed internal c_frexp2 to c_frexp r=disruptek a=saem

internal proc rename, no impact

412: options: remove deprecated UnpackError r=disruptek a=saem

## Summary

Removed UnpackError, was replaced with UnpackDefect a while back

## Details

Defects in general are a bad idea, but less code is good too

413: lang: remove for loop and case statement macros r=disruptek a=saem

There are better ways to do these sorts of things.

Co-authored-by: Saem Ghani <saemghani+github@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants