Skip to content

Commit

Permalink
not allow override of generic base type in global scope
Browse files Browse the repository at this point in the history
  • Loading branch information
sekiguchi-nagisa committed Aug 9, 2023
1 parent 41e8b3b commit 3b1b5cb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- ``MODULE_HOME`` indicates ``XDG_DATA_HOME/modules``
- ``MODULE_DIR`` indicates ``DATA_DIR/modules``
- completion script directory indicates ``DATA_DIR/completions``
- **Breaking Change**: not allow override of generic base type in global scope
- improve error message of type lookup errors
- report correct position of invalid type elements
- report more detailed error message for invalid type elements
Expand Down
3 changes: 1 addition & 2 deletions src/scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ NameRegisterResult NameScope::defineAlias(std::string &&name, const HandlePtr &h
NameRegisterResult NameScope::defineTypeAlias(const TypePool &pool, const std::string &name,
const DSType &type) {
if (this->isGlobal()) {
auto ret = pool.getType(name);
if (ret) {
if (pool.getType(name) || pool.getTypeTemplate(name)) {
return Err(NameRegisterError::DEFINED);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/exec/cases/always_failed/typedef_alias1.ds
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
##$test($result = 'type', $status = 1, $chars = 9, $errorKind = 'DefinedTypeAlias', $lineNum = 8)
#$test($result = 'type', $status = 1, $chars = 9, $errorKind = 'DefinedTypeAlias', $lineNum = 8)

typedef catch = Int

assert(12 is catch) # allow any identifier


typedef Func = Int # allow generic template
typedef Func = Int # do not allow generic template
assert(12 is Func)

0 comments on commit 3b1b5cb

Please sign in to comment.