Silverleaf Nightshade (Solanum elaeagnifolium) is a very common, purple-flowered weed around Tucson, especially along roadsides, in alleys, and in vacant lots. It's yellow fruit looks similar to yellow cherry tomatoes, which is not surprising since nightshade and tomatoes are both members of the Potato Family (Solanaceae).
Unlike the fruit of tomato plants, Silverleaf Nightshade fruit is poisonous and contains the glycoalkaloid solanine as well as the tropane alkaloids scopolamine (hyoscine) and hyoscyamine (an isomer of atropine). The leaves and greenish, unripe fruit like these are the most poisonous parts of the plant. If you have young children or pets, I would recommend removing any Silverleaf Nightshade plants that you find growing in your yard.
As a child, I discovered what I thought was a yellow cherry tomato growing wild near my house, which I now believe was most likely a nightshade plant. I might have eaten one of the fruits, but luckily I've never liked uncooked tomatoes.