diff --git a/codon/parser/visitors/simplify/simplify.cpp b/codon/parser/visitors/simplify/simplify.cpp index 0b1343c9..4dca7099 100644 --- a/codon/parser/visitors/simplify/simplify.cpp +++ b/codon/parser/visitors/simplify/simplify.cpp @@ -88,9 +88,10 @@ SimplifyVisitor::apply(Cache *cache, const StmtPtr &node, const std::string &fil } // Reserve the following static identifiers. for (auto name : {"staticlen", "compile_error", "isinstance", "hasattr", "type", - "TypeVar", "Callable", "argv", "super"}) + "TypeVar", "Callable", "argv", "super", "superf", "fn"}) stdlib->generateCanonicalName(name); stdlib->add(SimplifyItem::Var, "super", "super", true); + stdlib->add(SimplifyItem::Var, "superf", "superf", true); // This code must be placed in a preamble (these are not POD types but are // referenced by the various preamble Function.N and Tuple.N stubs) diff --git a/codon/parser/visitors/typecheck/typecheck_expr.cpp b/codon/parser/visitors/typecheck/typecheck_expr.cpp index 3007302c..bc547469 100644 --- a/codon/parser/visitors/typecheck/typecheck_expr.cpp +++ b/codon/parser/visitors/typecheck/typecheck_expr.cpp @@ -1038,15 +1038,15 @@ ExprPtr TypecheckVisitor::transformCall(CallExpr *expr, const types::TypePtr &in seenNames.insert(i.name); } - if (expr->expr->isId("super")) { + if (expr->expr->isId("superf")) { if (ctx->bases.back().supers.empty()) - error("no matching super methods are available"); + error("no matching superf methods are available"); auto parentCls = ctx->bases.back().type->getFunc()->funcParent; auto m = findMatchingMethods(parentCls ? CAST(parentCls, types::ClassType) : nullptr, ctx->bases.back().supers, expr->args); if (m.empty()) - error("no matching super methods are available"); + error("no matching superf methods are available"); // LOG("found {} <- {}", ctx->bases.back().type->getFunc()->toString(), // m[0]->toString()); ExprPtr e = N(N(m[0]->ast->name), expr->args); diff --git a/test/parser/typecheck_stmt.codon b/test/parser/typecheck_stmt.codon index a3099c5c..1baa0fcd 100644 --- a/test/parser/typecheck_stmt.codon +++ b/test/parser/typecheck_stmt.codon @@ -299,19 +299,19 @@ def foo2(x): foo2(1) #: 2 foo2('s') #: 1 -#%% super,barebones +#%% superf,barebones class Foo: def foo(a): - # super(a) + # superf(a) print 'foo-1', a def foo(a: int): - super(a) + superf(a) print 'foo-2', a def foo(a: str): - super(a) + superf(a) print 'foo-3', a def foo(a): - super(a) + superf(a) print 'foo-4', a Foo.foo(1) #: foo-1 1 @@ -324,21 +324,21 @@ class Bear: @extend class Bear: def woof(x): - return super(x) + f' bear w--f {x}' + return superf(x) + f' bear w--f {x}' print Bear.woof('!') #: bear woof ! bear w--f ! class PolarBear(Bear): def woof(): - return 'polar ' + super('@') + return 'polar ' + superf('@') print PolarBear.woof() #: polar bear woof @ bear w--f @ -#%% super_error,barebones +#%% superf_error,barebones class Foo: def foo(a): - super(a) + superf(a) print 'foo-1', a Foo.foo(1) -#! no matching super methods are available +#! no matching superf methods are available #! while realizing Foo.foo:0