Namespacing for data constructors
- Dominant language
- Haskell
- Stars
- 113
- Forks
- 9
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 1
Description
The current implementation places all data constructor names in the global scope. We do not check for duplicated data constructor names, and in the case where duplicates are present, one overwrites the other:
**Fails**
```solidity
data Foo = Baz;
data Bar = Baz;
function main() {
let x = Baz;
let y : Foo = Baz;
}
```
```
Types do not match: Bar and Foo
- in:let y : Foo = Baz ;
- in:function main () {
let x = Baz ;
let y : Foo = Baz ;
}
```
**Accepted**
```
data Foo = Baz;
data Bar = Baz;
function main() {
let x = Baz;
let y : Bar = Baz;
}
```
**Solution**
Implement a namespace for all data constuctors (e.g. `Foo.Baz` and `Bar.Baz`) allowing duplication. Consider sugar (e.g. The `.` operator in lean, or c++ style ADL) to allow omitting the namespace qualifier in cases where a unique namespace can be inferred from the context.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the compiler entry points that register data constructors and resolve constructor names; the issue does not name specific files or tests. Compare the failing and accepted examples, then determine how qualified names such as Foo.Baz and Bar.Baz should be represented and resolved, with duplicate constructor names accepted without overwriting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, solidity
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100