Commit a16e602b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #1171 from kmod/undef_assert

Fix usage of undef variables
parents 1da14a3c 5aafab07
......@@ -2782,10 +2782,6 @@ public:
return rtn;
}
ConcreteCompilerVariable* makeConverted(IREmitter& emitter, VAR* var, ConcreteCompilerType* other_type) override {
if (other_type == other_type->getBoxType()) {
assert(other_type == UNKNOWN);
return emitter.getNone()->makeConverted(emitter, other_type);
}
llvm::Value* v = llvm::UndefValue::get(other_type->llvmType());
return new ConcreteCompilerVariable(other_type, v);
}
......
......@@ -922,7 +922,7 @@ private:
// trigger an exception, but the irgenerator will know that definitely-defined
// local symbols will not throw.
emitter.getBuilder()->CreateUnreachable();
exc_type = exc_value = exc_tb = emitter.getNone();
exc_type = exc_value = exc_tb = undefVariable();
// endBlock(DEAD);
}
......
......@@ -76,6 +76,9 @@ bool RefcountTracker::isNullable(llvm::Value* v) {
}
void RefcountTracker::refConsumed(llvm::Value* v, llvm::Instruction* inst) {
if (llvm::isa<UndefValue>(v))
return;
assert(this->vars[v].reftype != RefType::UNKNOWN);
this->refs_consumed[inst].push_back(v);
......@@ -632,6 +635,9 @@ void RefcountTracker::addRefcounts(IRGenState* irstate) {
if (rt->vars.count(v))
return;
if (llvm::isa<UndefValue>(v))
return;
auto t = v->getType();
auto p = llvm::dyn_cast<llvm::PointerType>(t);
if (!p) {
......
# Regression test: promoting an UNDEF to a known type
def f():
match = None # This could be a function that usually returns None but sometimes returns a string
if 0:
s = match.foo() or ""
print s
for i in xrange(10000):
f()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment