{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3073","repository_url":"https://api.github.com/repos/fish-shell/fish-shell","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3073/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3073/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3073/events","html_url":"https://github.com/fish-shell/fish-shell/issues/3073","id":156973867,"number":3073,"title":"Fish special variables bleed into function argument scope","user":{"login":"kopischke","id":80906,"avatar_url":"https://avatars.githubusercontent.com/u/80906?v=3","gravatar_id":"","url":"https://api.github.com/users/kopischke","html_url":"https://github.com/kopischke","followers_url":"https://api.github.com/users/kopischke/followers","following_url":"https://api.github.com/users/kopischke/following{/other_user}","gists_url":"https://api.github.com/users/kopischke/gists{/gist_id}","starred_url":"https://api.github.com/users/kopischke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kopischke/subscriptions","organizations_url":"https://api.github.com/users/kopischke/orgs","repos_url":"https://api.github.com/users/kopischke/repos","events_url":"https://api.github.com/users/kopischke/events{/privacy}","received_events_url":"https://api.github.com/users/kopischke/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fish-shell/fish-shell/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-26T12:37:35Z","updated_at":"2016-05-26T14:37:34Z","closed_at":null,"body":"<!--\r\nThanks for helping to make fish better!\r\n\r\nIf you are asking for help with fish, or you've found a bug:\r\n - Make sure it's not a known or solved issue, by searching https://github.com/fish-shell/fish-shell/issues\r\n - Fill in the following information carefully:\r\n\r\n-->\r\n\r\nWhen defining a named argument to a function with the same name as a lower-case Fish special variable, the variable is not shadowed by the corresponding `$argv` value but assigned to the argument instead.\r\n\r\n### Reproduction Steps:\r\n\r\n1. `function testver --argument-names version; echo $version; end`\r\n2. `testver 1.2`\r\n\r\n### Expected behavior:\r\n\r\nCall outputs “1.2”\r\n\r\n### Observed behavior:\r\n\r\nCall outputs “2.3”\r\n\r\n### Additional information:\r\n\r\n- Reproducible with other Fish specific special variables like `$status`\r\n- Not reproducible with common exported shell variables like `$HOME`\r\n\r\n---\r\n- Fish version: 2.3, Homebrew installed via `brew install fish --devel`\r\n- Operating system: OS X 10.11.4\r\n- Terminal or terminal emulator: Terminal.app\r\n"},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/221889755","html_url":"https://github.com/fish-shell/fish-shell/issues/3073#issuecomment-221889755","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3073","id":221889755,"user":{"login":"kopischke","id":80906,"avatar_url":"https://avatars.githubusercontent.com/u/80906?v=3","gravatar_id":"","url":"https://api.github.com/users/kopischke","html_url":"https://github.com/kopischke","followers_url":"https://api.github.com/users/kopischke/followers","following_url":"https://api.github.com/users/kopischke/following{/other_user}","gists_url":"https://api.github.com/users/kopischke/gists{/gist_id}","starred_url":"https://api.github.com/users/kopischke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kopischke/subscriptions","organizations_url":"https://api.github.com/users/kopischke/orgs","repos_url":"https://api.github.com/users/kopischke/repos","events_url":"https://api.github.com/users/kopischke/events{/privacy}","received_events_url":"https://api.github.com/users/kopischke/received_events","type":"User","site_admin":false},"created_at":"2016-05-26T14:37:34Z","updated_at":"2016-05-26T14:37:34Z","body":"> For `$status` and such, we probably want to error out when you try to use them here - like we already do when you try to write to them.\r\n\r\nHmmm … AFAICS, declaring a named argument means the argument is in function local scope, shadowing any outer scope variable, i.e.\r\n\r\n```fish\r\nset -gx MYVAR foo\r\nfunction testvar --argument-names MYVAR\r\n    echo $MYVAR\r\nend\r\ntestvar bar\r\necho $MYVAR\r\n```\r\n\r\nechoes “bar”, then “foo”. I would expect special variables to be shadowed the same way, not to get special treatment (or rather: a different form of special treatment than the one they get now)."}}
{"actor":{"display_login":"kopischke"}}