View Issue Details

IDProjectCategoryView StatusLast Update
0000844LDMudLPC Languagepublic2021-04-16 19:40
Reportersinnvoll Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionwon't fix 
Summary0000844: warning against duplication by creating a mapping with ([
DescriptionThe compiler could warn against duplicate keys by creating a mapping with ([
Steps To Reproduce> zlpc return ([1:2,1:3])
Got=([1:3])
TagsNo tags attached.
External Data (URL)

Activities

Gnomi

2015-10-16 23:10

manager   ~0002265

Last edited: 2015-10-16 23:11

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.

Gnomi

2021-04-16 19:40

manager   ~0002599

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.

Issue History

Date Modified Username Field Change
2015-10-16 17:01 sinnvoll New Issue
2015-10-16 23:10 Gnomi Note Added: 0002265
2015-10-16 23:11 Gnomi Note Edited: 0002265
2021-04-16 19:40 Gnomi Status new => closed
2021-04-16 19:40 Gnomi Resolution open => won't fix
2021-04-16 19:40 Gnomi Note Added: 0002599