{"action":"created","issue":{"url":"https://api.github.com/repos/p4lang/p4c/issues/780","repository_url":"https://api.github.com/repos/p4lang/p4c","labels_url":"https://api.github.com/repos/p4lang/p4c/issues/780/labels{/name}","comments_url":"https://api.github.com/repos/p4lang/p4c/issues/780/comments","events_url":"https://api.github.com/repos/p4lang/p4c/issues/780/events","html_url":"https://github.com/p4lang/p4c/issues/780","id":243919487,"number":780,"title":"Bogus \"duplicates declaration\" error","user":{"login":"jnfoster","id":1843922,"avatar_url":"https://avatars0.githubusercontent.com/u/1843922?v=4","gravatar_id":"","url":"https://api.github.com/users/jnfoster","html_url":"https://github.com/jnfoster","followers_url":"https://api.github.com/users/jnfoster/followers","following_url":"https://api.github.com/users/jnfoster/following{/other_user}","gists_url":"https://api.github.com/users/jnfoster/gists{/gist_id}","starred_url":"https://api.github.com/users/jnfoster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnfoster/subscriptions","organizations_url":"https://api.github.com/users/jnfoster/orgs","repos_url":"https://api.github.com/users/jnfoster/repos","events_url":"https://api.github.com/users/jnfoster/events{/privacy}","received_events_url":"https://api.github.com/users/jnfoster/received_events","type":"User","site_admin":false},"labels":[{"id":352540661,"url":"https://api.github.com/repos/p4lang/p4c/labels/bug","name":"bug","color":"ee0701","default":true},{"id":500148585,"url":"https://api.github.com/repos/p4lang/p4c/labels/fixed","name":"fixed","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":{"login":"mbudiu-vmw","id":19397042,"avatar_url":"https://avatars1.githubusercontent.com/u/19397042?v=4","gravatar_id":"","url":"https://api.github.com/users/mbudiu-vmw","html_url":"https://github.com/mbudiu-vmw","followers_url":"https://api.github.com/users/mbudiu-vmw/followers","following_url":"https://api.github.com/users/mbudiu-vmw/following{/other_user}","gists_url":"https://api.github.com/users/mbudiu-vmw/gists{/gist_id}","starred_url":"https://api.github.com/users/mbudiu-vmw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbudiu-vmw/subscriptions","organizations_url":"https://api.github.com/users/mbudiu-vmw/orgs","repos_url":"https://api.github.com/users/mbudiu-vmw/repos","events_url":"https://api.github.com/users/mbudiu-vmw/events{/privacy}","received_events_url":"https://api.github.com/users/mbudiu-vmw/received_events","type":"User","site_admin":false},"assignees":[{"login":"mbudiu-vmw","id":19397042,"avatar_url":"https://avatars1.githubusercontent.com/u/19397042?v=4","gravatar_id":"","url":"https://api.github.com/users/mbudiu-vmw","html_url":"https://github.com/mbudiu-vmw","followers_url":"https://api.github.com/users/mbudiu-vmw/followers","following_url":"https://api.github.com/users/mbudiu-vmw/following{/other_user}","gists_url":"https://api.github.com/users/mbudiu-vmw/gists{/gist_id}","starred_url":"https://api.github.com/users/mbudiu-vmw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbudiu-vmw/subscriptions","organizations_url":"https://api.github.com/users/mbudiu-vmw/orgs","repos_url":"https://api.github.com/users/mbudiu-vmw/repos","events_url":"https://api.github.com/users/mbudiu-vmw/events{/privacy}","received_events_url":"https://api.github.com/users/mbudiu-vmw/received_events","type":"User","site_admin":false}],"milestone":null,"comments":11,"created_at":"2017-07-19T04:29:51Z","updated_at":"2017-08-23T04:52:53Z","closed_at":null,"body":"Compiling the following P4-14 program,\r\n```\r\nheader_type headers {\r\n  fields {\r\n    counterrevolution : 32;\r\n    cartographers : 8;\r\n    wadded : 8;\r\n    terns : 32;\r\n    miscellaneous : 8;\r\n  }\r\n}\r\nheader headers heartlands;\r\nparser start {\r\n  return ingress;\r\n}\r\naction add_heartlands() {\r\n  add_header(heartlands);\r\n}\r\ncontrol ingress { }\r\n```\r\nproduces a mysterious error:\r\n```\r\n% p4test --p4-14 ~/Downloads/envelop.p4 \r\nenvelop.p4(1): error: struct headers: Duplicates declaration header headers\r\nheader_type headers {\r\n^\r\nerror: 1 errors encountered, aborting compilation\r\n```\r\nIf I change `headers` to `foo`, then it converts just fine:\r\n```\r\n#include <core.p4>\r\n#include <v1model.p4>\r\n\r\nheader foo {\r\n    bit<32> counterrevolution;\r\n    bit<8>  cartographers;\r\n    bit<8>  wadded;\r\n    bit<32> terns;\r\n    bit<8>  miscellaneous;\r\n}\r\n\r\nstruct metadata {\r\n}\r\n\r\nstruct headers {\r\n    @name(\"heartlands\") \r\n    foo heartlands;\r\n}\r\n\r\nparser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {\r\n    @name(\".start\") state start {\r\n        transition accept;\r\n    }\r\n}\r\n\r\ncontrol ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {\r\n    apply {\r\n    }\r\n}\r\n\r\ncontrol egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {\r\n    apply {\r\n    }\r\n}\r\n\r\ncontrol DeparserImpl(packet_out packet, in headers hdr) {\r\n    apply {\r\n    }\r\n}\r\n\r\ncontrol verifyChecksum(in headers hdr, inout metadata meta) {\r\n    apply {\r\n    }\r\n}\r\n\r\ncontrol computeChecksum(inout headers hdr, inout metadata meta) {\r\n    apply {\r\n    }\r\n}\r\n\r\nV1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;\r\n```\r\nHence, it seems that `p4c` is introducing names that may or may not be unique, and/or not mangling the names in the source program to ensure there are no clashes."},"comment":{"url":"https://api.github.com/repos/p4lang/p4c/issues/comments/324220588","html_url":"https://github.com/p4lang/p4c/issues/780#issuecomment-324220588","issue_url":"https://api.github.com/repos/p4lang/p4c/issues/780","id":324220588,"user":{"login":"mbudiu-vmw","id":19397042,"avatar_url":"https://avatars1.githubusercontent.com/u/19397042?v=4","gravatar_id":"","url":"https://api.github.com/users/mbudiu-vmw","html_url":"https://github.com/mbudiu-vmw","followers_url":"https://api.github.com/users/mbudiu-vmw/followers","following_url":"https://api.github.com/users/mbudiu-vmw/following{/other_user}","gists_url":"https://api.github.com/users/mbudiu-vmw/gists{/gist_id}","starred_url":"https://api.github.com/users/mbudiu-vmw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbudiu-vmw/subscriptions","organizations_url":"https://api.github.com/users/mbudiu-vmw/orgs","repos_url":"https://api.github.com/users/mbudiu-vmw/repos","events_url":"https://api.github.com/users/mbudiu-vmw/events{/privacy}","received_events_url":"https://api.github.com/users/mbudiu-vmw/received_events","type":"User","site_admin":false},"created_at":"2017-08-23T04:52:53Z","updated_at":"2017-08-23T04:52:53Z","body":"Each fix comes with a reproduction test which usually copies the example filed with the issue. So if the tests pass the issue should be fixed. The test is named like the issue, e.g. Issue780.p4"}}
{"actor":{"display_login":"mbudiu-vmw"}}