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 cast warnings don't contain source code info #4839

Closed
strongoier opened this issue Apr 22, 2022 · 0 comments · Fixed by #4840
Closed

Type cast warnings don't contain source code info #4839

strongoier opened this issue Apr 22, 2022 · 0 comments · Fixed by #4840
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed
Milestone

Comments

@strongoier
Copy link
Contributor

Describe the bug
After #4834, the following code snippet,

import taichi as ti

ti.init()

x = ti.field(dtype=ti.i32, shape=())

@ti.kernel
def bug_gen():
    x[None] = 1.0

bug_gen()

will be warned about implicit type cast:

[Taichi] version 1.0.1, llvm 10.0.0, commit ecc0521f, linux, python 3.8.10
[Taichi] Starting on arch=x64
[W 04/22/22 13:25:16.293 193499] [type_check.cpp:visit@223] [$8] Global store may lose precision: i32 <- f32, at
  File "/home/xuyi15/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree
    ASTTransformer()(ctx, tree)
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 20, in __call__
    return method(ctx, node)
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer.py", line 568, in build_Module
    build_stmt(ctx, stmt)
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 20, in __call__
    return method(ctx, node)
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer.py", line 516, in build_FunctionDef
    build_stmts(ctx, node.body)
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer.py", line 1223, in build_stmts
    build_stmt(ctx, stmt)
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 20, in __call__
    return method(ctx, node)
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer.py", line 89, in build_Assign
    ASTTransformer.build_assign_unpack(ctx, node_target, values,
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer.py", line 106, in build_assign_unpack
    return ASTTransformer.build_assign_basic(ctx, node_target, values,
  File "/home/xuyi15/taichi/python/taichi/lang/ast/ast_transformer.py", line 153, in build_assign_basic
    var._assign(value)
  File "/home/xuyi15/taichi/python/taichi/lang/common_ops.py", line 262, in _assign
    return ops.assign(self, other)
  File "/home/xuyi15/taichi/python/taichi/lang/ops.py", line 118, in wrapped
    return imp_foo(a, b)

However, the stack trace info is around logic in Taichi's ASTTransformer. Users cannot know where the cast actually happens.

@strongoier strongoier added the potential bug Something that looks like a bug but not yet confirmed label Apr 22, 2022
@strongoier strongoier added this to the Taichi v1.0.1 milestone Apr 22, 2022
@strongoier strongoier self-assigned this Apr 22, 2022
@taichi-ci-bot taichi-ci-bot moved this to Untriaged in Taichi Lang Apr 22, 2022
Repository owner moved this from Untriaged to Done in Taichi Lang Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant