View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000844 | LDMud | LPC Language | public | 2015-10-16 17:01 | 2021-04-16 19:40 |
| Reporter | sinnvoll | Assigned To | |||
| Priority | normal | Severity | feature | Reproducibility | always |
| Status | closed | Resolution | won't fix | ||
| Summary | 0000844: warning against duplication by creating a mapping with ([ | ||||
| Description | The compiler could warn against duplicate keys by creating a mapping with ([ | ||||
| Steps To Reproduce | > zlpc return ([1:2,1:3]) Got=([1:3]) | ||||
| Tags | No tags attached. | ||||
| External Data (URL) | |||||
|
|
This isn't as easy as it looks: int fun1() { return 1;} int fun2() { return 1;} mapping fun() { return ([ fun1(): 2, fun2(): 3 ]); } Right now, this and return ([1:2,1:3]) is the same for the compiler, because there is no constant folding. So it doesn't matter whether there is '1' or 'fun1()'. To implement such a check the compiler needs to implement constant folding up to the point where the mapping is created at compile time to check for duplicate keys. (Which still might be tricky, because the values might not be constants, just the keys. Or only a part of the keys may be constant, others not.) So basically I don't see this happening at compile time anytime soon. Checking this at runtime would be a lot easier. |
|
|
The compiler currently can't detect these conditions and it would need a greater effort to do that. We feel that this effort doesn't justify the benefits. And we also don't want to check that at runtime, because there duplicate keys (when non constant) might be intentional. |